tostring()方法和tobytes()方法看起来是一样的,有什么区别呢?
from array import array
array1 = array('i',[1,2,3,4,5])
str1 = array1.tostring()
print(str1)
byt1 = array1.tobytes()
print(byt1) 发布于 2021-04-26 13:46:35
没有区别,tostring它们都是相同方法的别名,为了清楚起见,在Python3.2,as mentioned in the documentation中将tostring重命名为tobytes
保留tostring是为了向后兼容,但不建议使用tostring。
https://stackoverflow.com/questions/67249491
复制相似问题