|
本帖最后由 vinsonpyg 于 2018-7-13 07:05 编辑
def chkfilepro(path):
f= open(path,'r')
for i in f.readlines():
return i
f.close()
if __name__ == "__main__":
list1 = str(sys.argv[1].strip())
if len(sys.argv) != 2:
print "please use right list file"
if not os.path.exists(list1):
print "the files is not exists, please enter righat path"
else:
fil= open(list1.strip(),'r')
for path in fil:
o=chkfilepro(path.strip())
print o,
fil.close()
我在练习函数,当我使用hs.py d:\temp\list.txt ,其中list.txt中有三个文本文件,这个程序功能在于打印那例表中的文件,帮忙看下.但以上代码只打印了列表中每个文件的一行。
|
|