TypeError:stat()参数1必须是不带空字节的编码字符串,而不是str

2024-09-27 17:46:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试让服务器检查文件是否存在

以下内容来自服务器:

filename = sock.recv(1024)
strfilename = b'filename'

#if file exist,
if os.path.exists(filename):
    sock.send("fEXISTS" + (os.path.getsize(strfilename)))
    clientReply = sock.recv(1024)

以下是来自客户的信息

filename = raw_input("What file do you wish to download? -> ")

if filename != 'q':
    ssl_sock.send(filename)

Tags: 文件path服务器sendifosexistsfilename

热门问题