169 lines
5.2 KiB
Plaintext
169 lines
5.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"c:\\Users\\admin\\.conda\\envs\\F6processing\\lib\\site-packages\\numpy\\_distributor_init.py:30: UserWarning: loaded more than 1 DLL from .libs:\n",
|
|
"c:\\Users\\admin\\.conda\\envs\\F6processing\\lib\\site-packages\\numpy\\.libs\\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll\n",
|
|
"c:\\Users\\admin\\.conda\\envs\\F6processing\\lib\\site-packages\\numpy\\.libs\\libopenblas64__v0.3.21-gcc_10_3_0.dll\n",
|
|
" warnings.warn(\"loaded more than 1 DLL from .libs:\"\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"import time\n",
|
|
"import requests\n",
|
|
"import json\n",
|
|
"import xlwt\n",
|
|
"import xlrd\n",
|
|
"\n",
|
|
"\n",
|
|
"df1 = pd.read_excel(r'C:\\Users\\admin\\Desktop\\库存配件查询.xls',sheet_name='导出计数_产地',dtype='string') \n",
|
|
"for item in df1.index:\n",
|
|
" new_brand_name= df1.loc[item,'品牌新建']\n",
|
|
"\n",
|
|
" data = {\n",
|
|
" \"partBrandName\": new_brand_name \n",
|
|
" }\n",
|
|
" cookies_str = 'f6-ids-goodsSESSIONID=33b3add2-c869-46d3-b4ec-163bfc628018; sajssdk_2015_cross_new_user=1; erpLanguage=zh-CN; prodOrg=11240984669917991522; unp=15815448158550388788; _up=-NillNN-qyBEJ--t3vnSknvoOF53zPSJtMUE1nM6X-deXvnGr5HQjaZJ9Q3d-WrAAGgt60MgQHajHWBHMKKxj0CuWypi1JgKCFP1EPEk-HbqFfURqI8m0gsM-vNRv-ZNHu3M-GTc1pm0EXOgr-hdjO4ak17LORtnrEj9nxiw_Mi4PBA.; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2215815448158550388788%22%2C%22first_id%22%3A%2218fa83be71061f-03f4b144c21fe2c-26001c51-1327104-18fa83be711283%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%2218fa83be71061f-03f4b144c21fe2c-26001c51-1327104-18fa83be711283%22%7D; tmall=false'\n",
|
|
" cookies_str = cookies_str.encode('utf-8').decode('latin-1')\n",
|
|
"\n",
|
|
" cookie_dict = {item.split('=')[0]: item.split('=')[1]\n",
|
|
" for item in cookies_str.split('; ')}\n",
|
|
" url ='https://ids-goods.f6car.com/f6-ids-goods/brand/checkDuplicateBrand?brandName='+new_brand_name\n",
|
|
"\n",
|
|
" headers = {\n",
|
|
" 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',\n",
|
|
" \"Content-Type\": \"application/json;charset=UTF-8\",\n",
|
|
" 'origin': 'https://ids-goods.f6car.com'\n",
|
|
" }\n",
|
|
"\n",
|
|
" if requests.get(url = url,cookies=cookie_dict,headers=headers).json().get('data'):\n",
|
|
"\n",
|
|
" res = requests.post(f'https://ids-goods.f6car.com/f6-ids-goods/brand/addTmCustomPartBrand', \n",
|
|
" headers=headers,cookies=cookie_dict, json=data)\n",
|
|
" print(f'品牌:{new_brand_name} 新建成功')\n",
|
|
" else:\n",
|
|
" print(f'品牌:{new_brand_name} 重复,无法新建')\n"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## python 中的格式化字符串"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "",
|
|
"evalue": "",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m运行具有“F6processing (Python 3.9.4)”的单元格需要ipykernel包。\n",
|
|
"\u001b[1;31m运行以下命令,将 \"ipykernel\" 安装到 Python 环境中。\n",
|
|
"\u001b[1;31m命令: \"conda install -n F6processing ipykernel --update-deps --force-reinstall\""
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"a = 15\n",
|
|
"b = 3.14\n",
|
|
"# 1. %\n",
|
|
"print('abc%d,%.2f'%(a,b))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'abc12ddd'"
|
|
]
|
|
},
|
|
"execution_count": 19,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"a = 12\n",
|
|
"b = 3.14\n",
|
|
"\n",
|
|
"\"abc\"+str(a)+'ddd'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'ghjk12,3.14'"
|
|
]
|
|
},
|
|
"execution_count": 20,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# f字符串\n",
|
|
"\n",
|
|
"f'ghjk{a},{b:.2f}'"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "F6",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.9.4"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "59310123ccd3619229d524789fb6029e22b3ae7206c94adf033078aa9a774872"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|