glob读取某个文件夹下的多个文件

 import os
 import sys
 import glob
 from datetime import date, time, datetime, timedelta
 from operator import itemgetter
 from math import exp, log, sqrt
  
  inputPath = sys.argv[1]
  for input_file in glob.glob(os.path.join(inputPath,'*.txt')):
      with open(input_file, 'r') as filereader:
          for row in filereader:
             print row

  

posted @ 2018-08-17 14:48  四季万花筒  阅读(558)  评论(0编辑  收藏  举报