我不知道为什么,但是当我开始测试这个时,无论我输入哪个字母,它都会丢弃打印("此文件被删除")而没有其他选项。嵌套if语句肯定有问题。
import os, shutil, send2trash
def delete_files(folder):
for folderName, subfolders, filenames in os.walk(folder):
for filename in filenames:
full_file_name = os.path.join(folderName, filename)
size = os.path.getsize(full_file_name)
if size > 100000000:
print(filename, size)
print("Do you want to delete this file?")
confirm = input("Y or N? ")
if confirm == "Y" or "y":
print("THIS FILE IS DELETED")
#send2trash.send2trash(filename)
elif confirm == "N" or "n":
print("Let`s keep this file!")
delete_files(r"M:\Tables_Field\Processing\!-=ieksejie dokumenti=-\!Emīls")