|
import os
os.chdir(r"D:\桌面\学Python,不加班——轻松实现办公自动化\源代码文件+数据文件\第3章")
for file in os.listdir():
path=os.path.abspath(file)
filesize=os.path.getsize(file)
if (filesize <2000) & (os.path.splitext(path)[1]!=".txt"):
os.remove(file)
运行不成功
PermissionError Traceback (most recent call last)~\AppData\Local\Temp/ipykernel_10444/41349168.py in <module> 5 filesize=os.path.getsize(file) 6 if (filesize <2000) & (os.path.splitext(path)[1]!=".txt"):----> 7 os.remove(file)PermissionError: [WinError 5] 拒绝访问。: '.ipynb_checkpoints'这是什么原因,怎么解决?
|
|