我正在尝试访问model.filefieldDjango中的,以使用该模块解析Python中的CSV文件csv。它可以在Windows上运行,但在Mac上可以达到以下目的:
model.filefield
Exception Type: Error Exception Value: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
这是代码:
myfile = customerbulk.objects.all()[0].fileup mydata = csv.reader(myfile) for email,mobile,name,civilid in mydata: print email,mobile,name,civilid
我终于找到了解决方案:
mypath = customerbulk.objects.get(pk=1).fileup.path o = open(mypath,'rU') mydata = csv.reader(o)