Request Help With Byte/String Problem
grant.b.edwards at gmail.com
Fri Dec 2 14:39:39 EST 2016
On 2016-12-02, Wildman via Python-list <python-list at python.org> wrote:
> On Fri, 02 Dec 2016 15:11:18 +0000, Grant Edwards wrote:
>> I don't know what the "addr" array contains, but if addr is a byte
>> string, then the "int()" call is not needed, in Pythong 3, a byte is
>> already an integer:
>> def format_ip(a):
>> return '.'.join(str(b) for b in a)
>> addr = b'\x12\x34\x56\x78'
> It is a byte string just like your 'addr =' example and
> the above code works perfectly.
More importantly, you've now learned about generator comprehensions
(aka generator expressions) and the string type's "join" method. ;)
Grant Edwards grant.b.edwards Yow! My Aunt MAUREEN was a
at military advisor to IKE &
gmail.com TINA TURNER!!
More information about the Python-list