1
我試圖用Python測試我的EC2 Micro實例。Python錯誤整數是必需的
我得到這似乎不言自明,但多數民衆贊成不是這樣的錯誤:
錯誤:需要一個整數
stress_test功能:
try:
bytes = random._urandom(512)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((self.host, int(self.port)))
s.setblocking(0)
s.sendto(bytes, (self.host, self.port))
except Exception, e:
print(str(e))
主要功能:
while True:
if threading.activeCount() < thread_limit:
stress_test(host_ip, host_port).start()
的錯誤是在這條線:s.sendto(bytes, (self.host, self.port))
但是,如果我試圖將其轉換爲初始化,當然我會得到一個錯誤invalid literal for int() with base 10
。
我也試過s.sendto(bytes(512), (self.host, self.port))
但後來我得到了'str' object is not callable
錯誤。
我做錯了什麼?
真的就是這樣,哇謝謝 – Prometheus
由於你的問題已經解決了我的答案,你可以[接受](https://stackoverflow.com/help/someone-answers)它。 –