[Python-3000] python3000 udp problem

Benjamin Peterson musiccomposition at gmail.com
Wed Jun 11 04:25:11 CEST 2008


On Tue, Jun 10, 2008 at 9:23 PM, Long Ge <long.muyi at gmail.com> wrote:
> import socket
>
> if __name__ == '__main__':
>     print("main")
>     udp = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
>     udp.sendto("1",0,('127.0.0.1',3722))
>     udp.close()
>
> output:
> main
> Traceback (most recent call last):
>   File "C:\Python30\Projects\udp.py", line 6, in <module>
>     udp.sendto("1",0,('127.0.0.1',3722))
> TypeError: sendto() argument 1 must be bytes or read-only buffer, not str
>
> what is the problem about argument 1?

You have to use bytes; try b"1".



-- 
Cheers,
Benjamin Peterson
"There's no place like 127.0.0.1."


More information about the Python-3000 mailing list