检查代码没有发现错误
import send2trash
baconFile = open(r'D:\OneDrive\Py\test\bacon.txt', 'a') # creates the file
baconFile.write('Bacon is not a vegetable.')
baconFile.close()
send2trash.send2trash(r'D:\OneDrive\Py\test\bacon.txt')
最后发现Py文件名send2trash.py可能会与模块名send2trash有冲突,修改成test_send2trash.py后正常。
后面又多试了几次,发现使用python自带的IDLE shell一切正常,使用Notepad++就有问题。
先这样吧