<分区>
我正在通过 python 中的 uart 传输文件文件夹。下面你看到了简单的功能,但是有一个问题,因为我得到了标题中的错误:IOError: [Errno 2] No such file or directory: '1.jpg'
where 1.jpg is one of测试文件夹中的文件。所以这很奇怪,因为程序知道它不存在的文件名?!我做错了什么?
def send2():
path = '/home/pi/Downloads/test/'
arr = os.listdir(path)
for x in arr:
with open(x, 'rb') as fh:
while True:
# send in 1024byte parts
chunk = fh.read(1024)
if not chunk: break
ser.write(chunk)