Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError
#1
Hi
I'm getting a syntax error on the print to file. Can someone correct me please?

Error:
C:\Python27\python.exe C:/Users/David/PycharmProjects/pythonProject2/venv/init_collapse.py File "C:/Users/David/PycharmProjects/pythonProject2/venv/init_collapse.py", line 236 print("%.8f" % (kxx[0, ii]), file=output) ^ SyntaxError: invalid syntax Process finished with exit code 1
with open(file_ls, "w") as output:
    output.write("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0], collapse_steps,))
    for ii in np.arange((np.shape(kxx)[1])):
        print("%.8f" % (kxx[0, ii]), file=output)
Reply
#2
You are writing code using some syntax that is from python3, but trying to run it with a python2 executable. The code is syntactically correct for python3.
Reply
#3
Thank you
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020