我不知道这里的错误是什么
我知道这很乱但是在客户端连接并发送消息后我得到了一个异常
这里的错误ID
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Heights\PortableApps\PortablePython2.7.6.1\App\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\Gadi Tepper\PycharmProjects\Connection1\functions.py", line 12, in check_available_message
user_uid = user.user_uid
AttributeError: Message instance has no attribute 'user_uid'
这是功能
import time
from message import *
from user import *
def check_available_message(messages, users):
while True:
for message in messages:
for user in users:
user_uid = user.user_uid
dest_uid = message.receiver_uid
if user_uid == dest_uid:
print("got here")
send_message(messages, message, user.user_socket)
def send_message(messages, message, user_socket):
print(message.sender_uid + " can send a message to: " + message.sender_uid)
time.sleep(1)
data = str((message.receiver_uid + "//" + message.sender_uid + "//" + message.data)).encode
user_socket.send(data)
messages.remove(message)
这些是对象
class User:
def __init__(self, user_uid, user_socket):
self.user_uid = user_uid
self.user_socket = user_socket
class Message:
def __init__(self, sender_uid, receiver_uid, data):
self.sender_uid = sender_uid
self.receiver_uid = receiver_uid
self.data = data
互换的青春
繁星淼淼
相关分类