Reputation: 2127
I'm literally using the same code as the official Betfair Developer
example, the only difference is that I'm putting the APP_KEY_HERE
and SESSION_TOKEN
data.
But unlike the site, Visual Studio Code
is giving me an error and a crash in the terminal.
Terminal response:
line 11
print json.dumps(json.loads(response.text), indent=3)
^
SyntaxError: invalid syntax
https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Getting+Started
What am I missing and what do I need to change to solve this problem?
Upvotes: 15
Views: 113890
Reputation: 51
I just wanted to put this here, even though this is not your problem. Pylance raised this issue because I was missing a "
character in the preceding line of code. So if you encounter this issue, check if any strings are missing quotation marks in previous lines.
Upvotes: 0
Reputation: 81
As mentioned in comments print ""
statement is written for Python 2.x and syntax for this version is not supported in VS Code.
However, you can use from __future__ import print_function
and start using print()
with the old interpreter or you can switch to (previously installed) Python 3.x using CTRL+SHIFT+P
-> Python:Select interpreter
.
Upvotes: 7
Reputation:
In python 3.x, you have to enclose the arguments in ()
.
print(json.dumps(json.loads(response.text), indent=3))
Upvotes: 32