Python使用for循环依次打开该目录下的各文件
导读:Python使用for循环依次打开该目录下的各文件?class="answer-text mb-10 "> import ospath = r"F:\Python\第一周作业\task"otherpath=r"F:\Pyth...
Python使用for循环依次打开该目录下的各文件?
class="answer-text mb-10 "> import ospath = r"F:\Python\第一周作业\task"otherpath=r"F:\Python\其它目录"for filename in os.listdir(path): print(path,filename) fullname=os.path.join(path,filename) if os.path.isfile(fullname): othername=os.path.join(otherpath,filename) otherfile=open(othername,'wb') for line in open(fullname,'rb'): for c in line: if not c.isdigit():otherfile.write(c) otherfile.close()
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Python使用for循环依次打开该目录下的各文件
本文地址: https://pptw.com/jishu/57517.html
