當前位置:編程學習大全網 - 電腦編程 - 使用python2.5 合並某文件夾裏所有文件,例如:(xxx.fasta)格式

使用python2.5 合並某文件夾裏所有文件,例如:(xxx.fasta)格式

import os

dir_name = "c:\somefolder"

file_list = [f_name for f_name in os.listdir(dir_name) if os.path.isfile(f_name) and f_name.endswith('.fasta')]

combine_file_name = "combine.txt"

f_combine = open(combine_file_name,"w")

for f_in_name in file_list:

f = open(f_in_name,'r')

for line in f.readlines():

f_combine.write(line)

f.close()

f_combine.close()

  • 上一篇:蘋果手機無法連接到itunes
  • 下一篇:簡單火箭2rcs噴口怎麽才可以用
  • copyright 2024編程學習大全網