Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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_Python 3.x_Python 3.5 - Fatal编程技术网

python字符串中存在无效语法问题

python字符串中存在无效语法问题,python,python-3.x,python-3.5,Python,Python 3.x,Python 3.5,我在docker容器上运行以下代码。当我在没有docker容器的情况下运行时,它工作得非常好,但是当我在docker容器上运行时,我收到了无效的语法。docker容器上的Python版本为3.5,而机器上的Python版本为3.6 print(f"{time.strftime('%H:%M:%S')} ( i ) : Switching to {current_server}...") 错误: File "client.py", line 21 pri

我在docker容器上运行以下代码。当我在没有docker容器的情况下运行时,它工作得非常好,但是当我在docker容器上运行时,我收到了无效的语法。docker容器上的Python版本为3.5,而机器上的Python版本为3.6

print(f"{time.strftime('%H:%M:%S')} ( i ) :  Switching to {current_server}...")
错误:

File "client.py", line 21
print(f"{time.strftime('%H:%M:%S')} ( i ) :  Switching to 
{current_server}...")
SyntaxError: invalid syntax

谢谢,非常感谢您的帮助,了解如何解决此格式问题。

f-strings是在python 3.6()中引入的。因此,在docker中运行Python 3.5可能是您出现问题的原因。

请包括错误跟踪