回复: strang thing:
守株待兔
1248283536 at qq.com
Mon Sep 12 23:08:57 EDT 2011
i change open into open1,it's ok now
import os
import csv
for name in os.listdir('/tmp/quote/'):
filename='/tmp/quote/'+name
file = open(filename,'r')
file.readline()
for row in csv.reader(file):
(date,open1,high,low,close,vol,adjclose) = (row[0], row[1], row[2], row[3],row[4], row[5], row[6])
print row[0], row[1], row[2], row[3],row[4], row[5], row[6]
but i want "open" to be my data field,not open1 to be my field ,
how can i do?
------------------ 原始邮件 ------------------
发件人: "Chris Angelico"<rosuav at gmail.com>;
发送时间: 2011年9月6日(星期二) 下午4:22
收件人: "python-list"<python-list at python.org>;
主题: Re: strang thing:
2011/9/6 守株待兔 <1248283536 at qq.com>:
> file = open(filename,'r')
> when i add (date,open,high,low,close,vol,adjclose) = (row[0], row[1],
You're assigning to the name "open", which is shadowing the built-in
of the same name. The second time through the loop, you're not calling
the usual open() function, you're trying to call your string. That's
what your error is telling you.
Hope that helps!
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110913/50e9c3c4/attachment.html>
More information about the Python-list
mailing list