默认情况下导出的字符串全是数字时,在excel中打开时会被自动转换成科学计数格式
import csv
field_order = ["会诊单号"]
with open("导出.csv", 'w', encoding="utf8", newline="") as csvfile:
writer = csv.DictWriter(csvfile, field_order)
writer.writeheader()
writer.writerow({"会诊单号": "20210217162737860175"})
只需要在字符串后面加转义字符'\t'即可变成字符串
import csv
field_order = ["会诊单号"]
with open("导出.csv", 'w', encoding="utf8", newline="") as csvfile:
writer = csv.DictWriter(csvfile, field_order)
writer.writeheader()
writer.writerow({"会诊单号": "20210217162737860175"+'\t'})
关注公众号「Python之禅」,回复「1024」免费获取Python资源