【发布时间】:2013-06-06 20:01:35
【问题描述】:
我有一个名为 Test '/Desktop/Test/' 的文件夹
我的文件夹中有几个文件(例如 1.fa,2.fa,3.fa,X.fa)
或'/Desktop/Test/1.fa','/Desktop/Test/2.fa','/Desktop/Test/3.fa','/Desktop/Test/X.fa'
我正在尝试在我的函数中创建一个元素以打开目录中的每个文件 '/Desktop/Test/' 以 .fa 结尾而不实际创建函数有 20 个左右的变量(我知道的唯一方法)
例子:
def simple(input):
#input would be the directory '/Desktop/Test/'
#for each .fa in the directory (eg. 1.fa, 2.fa, 3.fa, X.fa) i need it to create a list of all the strings within each file
#query=open(input,'r').read().split('\n') is what I would use in my simple codes that only have one input
如何输入一个以特定结尾(.fa)的目录中的所有文件?
【问题讨论】:
标签: python file function input directory