可以复用的代码Excel2Json

1.调取URL

base_url = "http:..."
payload = {
    "entity_name": "123"
}
headers = {'Content-Type': 'application/json'}
res = requests.post(base_url, json=payload, headers=headers)
res.text
res.encoding = 'utf-8'
json = res.json()#转换成JSON

2.读取xlsx

# 读取
df = pd.read_excel(r'data.xlsx')
print(df.head())
df2.to_excel('可以利用的数据.xlsx', sheet_name = 'testing', index = False)
print('Done')

3.将字典d转换为json字符串,写入文件前要有这一步

dic_json = json.dumps(d,ensure_ascii=False,indent=4)
原文地址:https://www.cnblogs.com/Tony100K/p/15177228.html