-1
我有一個bytearray
緩衝液:如何清理和計數bytearray的?
buffer = bytearray() #creates the buffer
我的陣列應具有500個字節大小的最大值。
我要的是:緩衝區充滿500個字節
後,我要清理陣列並從頭開始再次追加。
if (buffer.count() >= 500) #ERROR!! count()
buffer.clean() #ERROR!! clean?!
buffer.append(10) #appends some value to the array
- 我怎麼能算當前數組的大小?
count()
需要一個參數,但在這個例子中,應該是什麼?
我知道this post,但不清楚我該如何計算我的陣列中有多少人。 b.count(b'a')
- 如何清理陣列?或者我怎樣才能設置「指針」再次在數組的開始?
怎麼樣'LEN(緩衝)'和'buffer.clear ()'? – vaultah