Python request SyntaxError: invalid syntax
Python request SyntaxError: invalid syntax
我写了一个 Python3.7.1 代码,我需要 运行 它在 Python3.5 中(因为我必须从 Raspberry 运行 它) ,出现错误:
teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
SyntaxError: invalid syntax
错误出现在第一个逗号(...standings', headers...)
我想这是因为 python3.5 不支持与 3.7.
相同的东西
我尝试在 raspberry 中安装 Python 3.7,但效果不佳
teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
感谢您的帮助
这里的问题是从 python 3.6 开始支持 f 字符串。当您使用 python 3.5 时,您可以使用等效的:
url = 'http://api.football-data.org/v2/competitions/{}/standings'.format(league)
Here 您可以找到一些关于字符串格式的信息。
我写了一个 Python3.7.1 代码,我需要 运行 它在 Python3.5 中(因为我必须从 Raspberry 运行 它) ,出现错误:
teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
SyntaxError: invalid syntax
错误出现在第一个逗号(...standings', headers...)
我想这是因为 python3.5 不支持与 3.7.
相同的东西我尝试在 raspberry 中安装 Python 3.7,但效果不佳
teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
感谢您的帮助
这里的问题是从 python 3.6 开始支持 f 字符串。当您使用 python 3.5 时,您可以使用等效的:
url = 'http://api.football-data.org/v2/competitions/{}/standings'.format(league)
Here 您可以找到一些关于字符串格式的信息。