我试图简单地打开一个 csv 文件,并打印出该文件中的行。当我将文件作为字符串传递给此函数时,输出是字符串的内容,而不是文件的行。
def _print_rows(filename):
with open(filename, 'rt') as opened_file:
read_file = csv.reader(opened_file):
for row in read_file:
print row
raw_input()
opened_file.close()
>>> module_name._print_rows('first_class_profile.csv')
['f']
['i']
['r']
['s']
['t']
['_']