Request Help With Byte/String Problem

Wildman best_lay at yahoo.com
Fri Dec 2 12:11:56 EST 2016


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'
> 
> print(format_ip(addr))

It is a byte string just like your 'addr =' example and
the above code works perfectly.  Thank you.

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!


More information about the Python-list mailing list