【发布时间】:2019-10-15 18:21:36
【问题描述】:
我正在使用以下命令:(python3)
Mydataframe__df.to_csv(string_io, sep=',', quoting=csv.QUOTE_ALL, header=True, index=False , encoding='utf-8')
df_writer = Mydata_Output.get_writer('/MYFILE_TEST.csv')
df_string = string_io.getvalue()
# save the string as bytes to with the writer
df_writer.write(df_string.encode('utf-8'))
# close the writer connection
df_writer.close()
问题在于格式为“012345”的列,即使使用记事本打开输出文件,即使列格式在数据框中设置为字符串,输出文件中的前导 0 也会被删除。
【问题讨论】:
标签: python-3.x formatting export-to-csv