简体   繁体   English

如何删除--- >>之后的读取文件(对于root,dirs,os.walk()中的文件)<< - 在python中使用函数os.remove()

[英]How can I delete the Read files after --->>(for root, dirs, files in os.walk()) <<— with function os.remove() in python

I want the program to automatically delete files. 我希望程序自动删除文件。

Function accept(os.remove(" ")) the variable in Loop(for). 函数接受(os.remove(“”))Loop(for)中的变量。

import shutil import threading import glob import os import shutil import threading import glob import os

def test():
    threading.Timer(5.0, test).start () # Was checked every 3 
    for  root, dirs, files in os.walk("/mydir"):
         for file in files: 
         print(file)
         os.remove(" ") #delete the file
         print("remove the file")

test() 测试()

I believe you want to find the real path of that file to remove it, This answer might help. 我相信你想找到该文件的真实路径来删除它,这个答案可能有所帮助。 Python cant get full path name of file Python无法获取文件的完整路径名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM