python-3.x - sock.bind() - TypeError: 需要一个整数
问题描述
我的 python 代码不接受字符串,而是需要整数,为什么?
sock.bind((UDP_IP,UDP_PORT)) Traceback(最近一次调用最后一次):文件“”,第 5 行,TypeError:需要一个整数(获取类型 str)
我的代码:
import socket
UDP_IP="localhost"
UDP_PORT="8080"
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((UDP_IP,UDP_PORT))
解决方案
推荐阅读
- jquery - 将(this)附加到辅助 jquery 元素
- python - DynamoDB 更新字段仅具有较大的值
- r - 在 R 中聚合每组的常见字符值
- ruby-on-rails - Selenium::WebDriver::Error::SessionNotCreatedError: session not created: 此版本的 ChromeDriver 仅支持 Chrome 版本 74
- r - 由于 timevar 未分离,因此重塑宽误差
- c# - 粒子系统无法播放
- python - 在我的文字游戏中使用 DSL,地图与我写的不匹配
- javascript - 如何在 html 中显示 JS 切片
- r - R:根据X,Ys从多个文件中提取数据
- typescript - elasticsearch更新给出未知字段错误