python 把mysql数据导入到execl中
import pymysql
import pandas as pd
db = pymysql.connect(
host='127.0.0.1',
user='root',
passwd='123456',
port=3306,
database='world',
charset='utf8'
)
pf = pd.read_sql("""
select * from city
""",con=db)
pf.to_excel("城市表.xlsx",index=False)