[英]What is the difference between tostring() and tobytes() methods of array?
tostring() 方法和 tobytes() 方法的工作方式似乎相同,有什么區別?
from array import array
array1 = array('i',[1,2,3,4,5])
str1 = array1.tostring()
print(str1)
byt1 = array1.tobytes()
print(byt1)
沒有區別, tostring
它們都是相同方法的別名, tostring
被重命名為tobytes
以在 Python 3.2 中清晰起見, 如文檔中所述
保留tostring
是為了向后兼容,但不推薦使用tostring
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.