简体   繁体   中英

running python executable from windows command line with arguments

I am using the windows7 command prompt and have opened the python interpreter and changed to the directory where the file is located. The instructions I have say to get into the directory and type

./keyboardControl.py 192.168.1.108

where keyboardControl.py is the name of the file and the ip address is for a robot.

I get the error:

File "", line 1 .\\keyboardControl.py 192.168.1.108 SyntaxError: invalid syntax (with the carrot under the . before )

I have also tried:

python keyboardControl.py 192.168.1.108

I get the same error with the carrot now under the l in Control.

Any help would be greatly appreciated.

It sounds like you've launched the Python interpreter and are typing these commands into the REPL. This is not what you should be doing. The commands should be run directly at the cmd prompt, eg:

C:\Users\me>keyboardControl.py 192.168.1.108

If that does not work (file associations might not be set correctly - Windows does not handle the #! "shebang") the form would be.

C:\Users\me>python keyboardControl.py 192.168.1.108

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