我在“useCv.py”中写了“switch”模块,但它一直说“module'useCv'没有属性'switch”
[我的代码]
>>> import os, re, usecsv
>>> os.chdir(r'/Users/macbookrocks/Downloads/practice')
>>> total = usecsv.opencsv('popSeoul.csv')
>>> newPop = usecsv.switch(total)
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
newPop = usecsv.switch(total)
NameError: name 'usecsv' is not defined
----------[usecsv.py]------------
import csv, os
def opencsv(filename):
f = open(filename, 'r')
reader = csv.reader(f)
output = []
for i in reader:
output.append(i)
return output
def writecsv(filename, the_list):
with open(filename, 'w' , newline = '') as f:
a = csv.writer(f, delimiter = ',')
a.writerows(the_list)
def switch(listName):
for i in listName:
for j in I:
try:
i[i.index(j)] = float(re.sub(',' , '' , j))
except:
pass
return listName
目前没有回答
相关问题 更多 >
编程相关推荐