I am a newb to python
. I am running a script I got on the web :
python file.py
I get this :
File "file.py", line 293
print json.dumps(evaluate(), indent=4)
^
SyntaxError: invalid syntax
I read it is related to python version, that should be some 2.7
. So I downloaded pyenv
. And I set the right version in the directory that contains file.py
: pyenv local 2.7.10
. But I still get the same error.
(For information, I am trying to install blockchain
tool : ethereum)
json. dump() method used to write Python serialized object as JSON formatted data into a file. json. dumps() method is used to encodes any Python object into JSON formatted String.
The json. dumps() method allows us to convert a python object into an equivalent JSON object. Or in other words to send the data from python to json.
loads() takes in a string and returns a json object. json. dumps() takes in a json object and returns a string.
it would append the new data. the problem with this approach is that it literally appends the data so that it ends up like {... original data...}{
Python 3.x changed print statement to be print functions
Python 2.x:
print "Hello World"
Python 3.x
print("Hello World")
So because you are running on python 3.x you will need to update your code to use the 3.x print style (e.g., print function calls).
print( json.dumps(evaluate(), indent=4) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With