Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python语法错误,找不到拼写错误的内容_Python_Sockets_Syntax Error - Fatal编程技术网

Python语法错误,找不到拼写错误的内容

Python语法错误,找不到拼写错误的内容,python,sockets,syntax-error,Python,Sockets,Syntax Error,我的pythonsocket程序中有这行代码,但它抛出了一个语法错误,看在上帝的份上,我找不到拼写错误的地方 conn.send(f'{os.path.getsize(f'{os.path.curdir}\\{filename}')}.encode(格式)) 下面是VisualStudio代码中的“偷窥问题”屏幕截图 无需嵌套f字符串: import os filename = "foo.txt" x = f"{os.path.getsize(os.path.j

我的pythonsocket程序中有这行代码,但它抛出了一个语法错误,看在上帝的份上,我找不到拼写错误的地方

conn.send(f'{os.path.getsize(f'{os.path.curdir}\\{filename}')}.encode(格式))
下面是VisualStudio代码中的“偷窥问题”屏幕截图


无需嵌套f字符串:

import os
filename = "foo.txt"

x = f"{os.path.getsize(os.path.join(os.path.curdir, filename))}"
print(x)
输出:


嵌套的
s?
7