file=open('data.csv','w')
header='product_name,Price,seller\n'
file.write(header)
答案 0 :(得分:2)
在MEDIA_ROOT
中设置 settings.py
,然后将文件打开为
from django.conf import settings
file_name = "{}data.csv".format(settings.MEDIA_ROOT)
file = open(file_name, 'w')