#!/usr/bin/python
import socket

s = socket.socket()

host = "172.16.103.195"
port = 8012
buf = "hello world"

s.connect((host, port))
s.send(buf)

这是一个完整的可以发送网络数据的客户端了。

还可以如果为了追求较少的行数 我想还可以写成如下

#!/usr/bin/python
import socket

s = socket.socket()
s.connect(("172.16.103.195", 8012))
s.send("hello world")

同样,也能正常工作。

相关文章:

  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-08-05
  • 2022-02-07
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2021-10-20
相关资源
相似解决方案