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"<[email protected]>;
发送时间: 2011年9月6日(星期二) 下午4:22
收件人: "python-list"<[email protected]>;
主题: Re: strang thing:
2011/9/6 守株待兔 <[email protected]>:
> 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
--
http://mail.python.org/mailman/listinfo/python-list