Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13205

回复: strang thing:

From "守株待兔" <1248283536@qq.com>
Subject 回复: strang thing:
Date 2011-09-13 11:08 +0800
Newsgroups comp.lang.python
Message-ID <mailman.1055.1315883354.27778.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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@gmail.com>;
发送时间: 2011年9月6日(星期二) 下午4:22
收件人: "python-list"<python-list@python.org>; 

主题: Re: strang thing:

 
2011/9/6 守株待兔 <1248283536@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

回复: strang thing: "守株待兔" <1248283536@qq.com> - 2011-09-13 11:08 +0800

csiph-web