Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python request SyntaxError: invalid syntax [duplicate]

I have written a Python3.7.1 code, and I need to run it in Python3.5 (because I have to run it from Raspberry), an error shows up:

teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()
SyntaxError: invalid syntax

The error appears on the first comma (...standings', headers...)

I suppose this is because of python3.5 don't support the same things that 3.7.

I have tried to install Python 3.7 in raspberry but have no good results

teams = requests.get(f'http://api.football-data.org/v2/competitions/{league}/standings', headers=headers, timeout = 10).json()

Thanks for the help

like image 777
pauescofet Avatar asked Oct 28 '25 09:10

pauescofet


1 Answers

The issue here is that the f string is supported since python 3.6. As you are using python 3.5, you can use an equivalent:

url = 'http://api.football-data.org/v2/competitions/{}/standings'.format(league)

Here you can find some information about string formatting.

like image 116
nero Avatar answered Oct 29 '25 22:10

nero