我正在运行这个程序:
f = open( "animals.txt", "r")
g = f.read()
g1 = g.split(',') #turning the file into list
print g1
我希望您能将其翻译为:
['ELDEN', 'DORSEY', 'DARELL', 'BRODERICK', 'ALONSO']
相反,我得到了这个:
['"ELDEN"', '"DORSEY"', '"DARELL"', '"BRODERICK"', '"ALONSO"']
有人知道如何去掉内部引号吗?
f.close()
或者使用 with 语句 打开文件以自动关闭它。 - user2555451