0
我想通過csv模塊製作csv文件。python csv模塊省略第一個字母'0'
問題導出CSV文件包含的第一個字母排「0」省略..
代碼:
import csv
from django.utils.encoding import smart_str
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=customer_email_who_reserved.csv'
writer = csv.writer(response, csv.excel)
writer.writerow([
smart_str(u"email"),
smart_str(u"phonenumber"),
])
for obj in queryset:
writer.writerow([
smart_str(obj.email),
'010',
])
而且奇怪的是PHONENUMBER行輸出爲「10 「而不是」010「。
我該如何解決這個問題?
在此先感謝!
如果你想添加一個[Minimal,Complete,and Verifiable](http://stackoverflow.com/help/mcve)例子,那就太好了。 –
難道是phonenumber是一個整數? – Pedru