python pandas 写入excel

 

pip install pandas openpyxl

 

import pandas as pd

from Silence.utils.login_util import Login
from Silence.utils.request_util import SendRequest


def test_fun():
    Login().login_system()
    method = 'GET'
    url = 'http://127.0.0.1/api/mgr/customers'
    params = {
        "action": "list_customer",
        "pagesize": 10000,
        "pagenum": 1,
        "keywords": "人民医院"
    }
    res = SendRequest.s.request(method, url, params=params)
    return res
res = test_fun()

# 创建一个DataFrame
data = res.json()['retlist']

df = pd.DataFrame(data)
# 将DataFrame写入EXCEL文件
df.to_excel('./tools/pandas写入excel.xlsx',index = False)

 

 

posted @ 2023-11-28 22:55  Avicii_2018  阅读(53)  评论(0编辑  收藏  举报