Python 3 http.server语法错误

时间:2014-12-19 14:42:34

标签: python-3.4

您好我尝试设置我的第一个简单的Python http服务器。这是我试过的。请帮忙。

>>>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 个答案:

答案 0 :(得分:3)

为解决方案提供资金。通常是一个愚蠢的错误。我不得不把命令放在windows命令行中而不是python本身。