Search code examples
pythonsys

python: invalid syntax on sys


I am new to Python,
I tried to execute file with code:

import sys
def main():
    print sys.argv[1]

main()

For this run: hello.py from command line, but got

C:\Python34>hello.py
File "C:\Python34\hello.py", line 4
print sys.argv[1]
        ^
SyntaxError: invalid syntax

Could someone help me with this issue?


Solution

  • Python 3.4 requires brackets parentheses around prints. E.g. print(sys.argv[1])