Home>

python: 3.5.3

I'm learning python.
Official document: https://docs.python.jp/3/tutorial/modules.html#importing-from-a-package
"6.1.1. Executing the module as a script"
I am learning the item.

I want to execute fibo.py as the main file with the command "python fibo.py 50".
I get a SyntaxError.

Error message
>>>python fibo.py 50
  File "<stdin>", line 1
    python fibo.py 50
              ^
SyntaxError: invalid syntax
Applicable source code
# Fibonacci numbers module
def fib (n): # write Fibonacci series up to n
    a, b = 0, 1
    while b<n:
        print (b, end = '')
        a, b = b, a + b
    print ()
def fib2 (n): # return Fibonacci series up to n
    result = []
    a, b = 0, 1
    while b<n:
        result.append (b)
        a, b = b, a + b
    return result
if __name__ == "__main__":
    import sys
    fib (int (sys.argv [1]))
Tried

I have checked the file name several times to see if it is correct.

The working file directory is already defined by sys.path.append (), and it is possible to import and execute the method.

Teach us how to solve the problem.