首页后端开发PythonPython使用for循环依次打开该目录下的各文件

Python使用for循环依次打开该目录下的各文件

时间2023-06-02 01:02:01发布访客分类Python浏览746
导读: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
请问什么时候才会有笨办法学Python这本书的中文第四版 AttributeError

游客 回复需填写必要信息