Python 2.7 python:如何使用python 2.7将包含字符串的列表传递给打开的文件对象

Python 2.7 python:如何使用python 2.7将包含字符串的列表传递给打开的文件对象,python-2.7,Python 2.7,locfile=['fileone','filetwo','filetthree'] myfile=open('locfile','rU') 正如您所看到的,open file对象也需要一个具有文件扩展名的字符串。 我只是想在每次处理一个文件名的列表时传入文件名。 我该怎么做? locfile = ['fileone','filetwo','filetthree'] for x in locfile: file = openfile(x,'rU')

locfile=['fileone','filetwo','filetthree']

myfile=open('locfile','rU')

正如您所看到的,open file对象也需要一个具有文件扩展名的字符串。 我只是想在每次处理一个文件名的列表时传入文件名。 我该怎么做?

locfile = ['fileone','filetwo','filetthree']
for x in locfile:
    file = openfile(x,'rU')