简体   繁体   中英

Python print statement ambiguity

I am running the following print statement in a file test.py within the Eclipse PyDev environment which gives the required output:

print(f"Epoch {j}: {self.evaluate(test_data)} / {n_test}")

However, when I attempt to run the same code from the file at the command prompt (OSX Terminal), I get the following

% python test.py
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    import simple_nn
  File "/Users/davidklemitz/eclipse-workspace/_neural/simple_nn.py", line 47
    print(f"Epoch {j}: {self.evaluate(test_data)} / {n_test}")
                                                            ^
SyntaxError: invalid syntax

Anybody have some clues to resolve the issue, thanks?

Looks like you use two different python versions in Eclipse and your terminal. Try

python3 test.py

in your terminal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM