
IT/파이썬 2021. 4. 14.
파이썬 bytearray 배열 reset 하기
마이크로파이썬 micropython 의 세계로 들어가고 있다. 점점..하다보니 bytearray를 새로 만드는 것은 정말 자료도 많이 있는데, 이미 만들어진 bytearray를 다시 리셋 시켜주는 코드를 찾기가 쉽지 않네. 물론 가장 쉽게 할 수 있는 방법은 for i in range(len(your_array)): your_array[i] = 0 요거 더 잘하는 방법이 있을 것 같아서 찾아본 결과. $ ./upython MicroPython v1.8.1-39-gdb4addd on 2016-07-01; linux version Use Ctrl-D to exit, Ctrl-E for paste mode >>> a = bytearray(10) >>> id(a) 139728051341376 >>> a[:] =..
