Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12818
| From | "守株待兔" <1248283536@qq.com> |
|---|---|
| Subject | strang thing: |
| Date | 2011-09-06 16:18 +0800 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.793.1315297135.27778.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
i found stange thing that i can't solve
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):
print row[0], row[1], row[2], row[3],row[4], row[5], row[6]
it's ok,
when i add (date,open,high,low,close,vol,adjclose) = (row[0], row[1], row[2], row[3],row[4], row[5], row[6])
change the code into
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,open,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]
the wrong output is :
file = open(filename,'r')
TypeError: 'str' object is not callable
i don't know why??
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
strang thing: "守株待兔" <1248283536@qq.com> - 2011-09-06 16:18 +0800
Re: strang thing: Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-13 13:28 +1000
Re: strang thing: Chris Angelico <rosuav@gmail.com> - 2011-09-13 13:42 +1000
csiph-web