append方法不能使用[程序崩溃,非append问题,已解决]
2021-03-062646
AI 快速预览详细
本文讨论了在字节数组中追加数据时遇到的问题,并提供了解决方案。当使用append方法时,可能会导致程序崩溃。正确的做法是将数据转换为字节,并使用extend方法来追加数据。这样可以避免程序崩溃,确保代码的稳定性。
|
为什么字节数组使用append方法直接和IDE断开连接,要想在数组后追加数据该怎么办呢 ![]() |
-
8O2U_G$(2O)]$UB5[_8FU~V.jpg (107.82 KB, 下载次数: 2631)

![append方法不能使用[程序崩溃,非append问题,已解决]图1](https://imagemc.dfrobot.com.cn/data/attachment/forum/202103/06/210311pq4qaa3ma40mwtsk.png?imageView2/2/format/webp/q/80)





import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
imgbytes=img.to_bytes()
imgbytes.append([200])
print(imgbytes[-1])
img_byte.append(1)[/code]
运行结果
并没有问题