簡體   English   中英

數組的 tostring() 和 tobytes() 方法有什么區別?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM