Python 3 http.server syntax error

我是研究僧i 提交于 2019-12-24 04:28:11

问题


Hi I try to set up my first simple Python http server. This is what I tried. Please help.

>>>import os
>>>os.chdir('/users/ds/my documents/pythonservers/frenchacademy')
>>>os.getcwd()
'C:\\users\\ds\\my documents\\pythonservers\\frenchacademy'
>>> python -m SimpleHTTPServer
SyntaxError: invalid syntax
>>> python -m SimpleHTTPServer 8000
SyntaxError: invalid syntax
>>> -m SimpleHTTPServer
SyntaxError: invalid syntax
>>> python -m http.server
SyntaxError: invalid syntax
>>> -m http.server
SyntaxError: invalid syntax
>>> --version
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
--version
NameError: name 'version' is not defined
>>> python --version
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
python --version
NameError: name 'python' is not defined
>>> $ python -m http.server
SyntaxError: invalid syntax
>>> python3 -m http.server
SyntaxError: invalid syntax
>>> -m http.server
SyntaxError: invalid syntax
>>> python3 -m http.server --help
 SyntaxError: invalid syntax

回答1:


Fund the solution. As usually a stupid error. I had to put the command in the windows command line and not in python itself.



来源:https://stackoverflow.com/questions/27568283/python-3-http-server-syntax-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!