[英]What's the equivalent of `array.array('c')` in python 3
My old code with python 2 has 我的python 2旧代码有
import array
buf = array.array('c')
In python 3, this chunk of code gives error 在python 3中,这段代码给出了错误
E ValueError: bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d) E ValueError:错误的类型代码(必须为b,B,u,h,H,i,I,l,L,q,Q,f或d)
What would be the equivalent in python 3? python 3相当于什么? How to make the code work for both python 2 and 3? 如何使代码适用于python 2和python 3?
Just check the manual: https://docs.python.org/3/library/array.html 只需查看手册即可: https : //docs.python.org/3/library/array.html
'b' signed char
'B' unsigned char
So you'll probably need B
(but we can't be sure - it depends on the rest of your code, I guess). 因此,您可能需要B
(但是我们不能确定-这取决于您代码的其余部分)。 This is also compatible with Python 2.x. 这也与Python 2.x兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.