I'm experimenting with bytes
vs bytearray
in Python 2.6. I don't understand the reason for some differences.
A bytes
iterator returns strings:
for i in bytes(b"hi"):
print(type(i))
Gives:
<type 'str'>
<type 'str'>
But a bytearray
iterator returns int
s:
for i in bytearray(b"hi"):
print(type(i))
Gives:
<type 'int'>
<type 'int'>
Why the difference?
I'd like to write code that will translate well into Python 3. So, is the situation the same in Python 3?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…