os.remove()删除文件报错,是什么原因?
-
import sensor, image, time, os from pid import PID from pyb import Servo from pyb import LED from pyb import Pin from pyb import UART pan_servo=Servo(1) tilt_servo=Servo(2) p_out = Pin('P6', Pin.OUT_PP) pan_servo.calibration(500,2500,500) tilt_servo.calibration(500,2500,500) red_threshold = (9, 39, 20, 102, 3, 101) fire_threshold = (90, 100, -7, 56, -32, 4) m_threshold = (9, 39, 20, 102, 3, 101) pan_pid = PID(p=0.04, i=0.02, d=0.004,imax=90) #脱机运行或者禁用图像传输,使用这个PID tilt_pid = PID(p=0.03, i=0.015, d=0.004,imax=90) #脱机运行或者禁用图像传输,使用这个PID #pan_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID #tilt_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID print('mulu', os.listdir(os.getcwd())) os.remove("temp")
运行结果:mulu ['.openmv_disk', 'temp', 'README.txt', 'System Volume Information', 'tanke.pgm', 'pid.py', 'main.py']
File “”, line 32, in
OSError: [Errno 21] EISDIR
没有插sd卡,想删除temp这个文件,为什么会报错?
-
os.remove() 只能删除文件,不能删除目录