以下为我编程期间遇到的错误并进行记录,起始时间2017-6-21 ----------------------------------------Exception happened during processing of request from (‘127.0.0.1‘, 48039)Traceback (most recent call last): File "/opt/python3/lib/python3.6/socketserver.py", line 639, in process_request_thread self.finish_request(request, client_address) File "/opt/python3/lib/python3.6/socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "/opt/python3/lib/python3.6/socketserver.py", line 696, in __init__ self.handle() File "/root/python_study/high_ftp/core/main.py", line 84, in handle recv_cmd = self.request.recv(1024).decode()UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd3 in position 1: invalid continuation byte发现计算文件大小使用了len,使用方式不对。修改使用了os.path.getsize计算 Exception happened during processing of request from (‘127.0.0.1‘, 4316)Traceback (most recent call last): File "C:\Python36-32\lib\socketserver.py", line 639, in process_request_thread self.finish_request(request, client_address) File "C:\Python36-32\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python36-32\lib\socketserver.py", line 696, in __init__ self.handle() File "D:\51cto\python\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 106, in handle out_result = fun(**cmd_json) File "D:\51cto\python\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 68, in put new_file_md5 = m.hexdegest()AttributeError: ‘_hashlib.HASH‘ object has no attribute ‘hexdegest‘拼写错误了 Traceback (most recent call last): File "D:/1_oldboyS14_Py/Advance4/homework/Adv_ftp/high_ftp/ftpclient/ftpclient_core.py", line 121, in <module> ftp.interaction() File "D:/1_oldboyS14_Py/Advance4/homework/Adv_ftp/high_ftp/ftpclient/ftpclient_core.py", line 48, in interaction out = func(mess)TypeError: get() takes 1 positional argument but 2 were given原因是:发现我定义了2个同名的函数,导致出错 Traceback (most recent call last): File "D:/1_oldboyS14_Py/Advance4/homework/Adv_ftp/high_ftp/ftpclient/ftpclient_core.py", line 123, in <module> ftp.interaction() File "D:/1_oldboyS14_Py/Advance4/homework/Adv_ftp/high_ftp/ftpclient/ftpclient_core.py", line 48, in interaction out = func(mess) File "D:/1_oldboyS14_Py/Advance4/homework/Adv_ftp/high_ftp/ftpclient/ftpclient_core.py", line 66, in get if recv_msg[‘id‘] == ‘200‘:TypeError: string indices must be integers类型错误 ----------------------------------------Exception happened during processing of request from (‘127.0.0.1‘, 53957)Traceback (most recent call last): File "D:\Python36\lib\socketserver.py", line 639, in process_request_thread self.finish_request(request, client_address) File "D:\Python36\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "D:\Python36\lib\socketserver.py", line 696, in __init__ self.handle() File "D:\1_oldboyS14_Py\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 126, in handle out_result = fun(**cmd_json) File "D:\1_oldboyS14_Py\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 19, in get self.request.send(kwargs.encode(‘utf-8‘))AttributeError: ‘dict‘ object has no attribute ‘encode‘应该发送时候转换为字符串发送 ----------------------------------------Exception happened during processing of request from (‘127.0.0.1‘, 54134)Traceback (most recent call last): File "D:\Python36\lib\socketserver.py", line 639, in process_request_thread self.finish_request(request, client_address) File "D:\Python36\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "D:\Python36\lib\socketserver.py", line 696, in __init__ self.handle() File "D:\1_oldboyS14_Py\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 127, in handle out_result = fun(**cmd_json) File "D:\1_oldboyS14_Py\Advance4\homework\Adv_ftp\high_ftp\core\main.py", line 25, in get self.request.send(line.encode(‘utf-8‘))AttributeError: ‘bytes‘ object has no attribute ‘encode‘文件打开读取就是rb模式,所以这里不用在encode了
TypeError: argument of type ‘socket‘ is not iterable写错了应该是:if s is self.server: 写成 if s in self.server 新手都会这样
时间: 2024-11-07 18:47:14