根據您所提供的信息,它確實樣子你正在發行的Python內的命令。
編輯:也許部分混淆來自術語command line
。你在這兩個命令行中都是這個「Windows命令」的shell,也是你在「Python shell」裏面的時候。
這是我在命令行時得到了Python殼內:
D:\Users\blabla \Desktop>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python testit.py
File "<stdin>", line 1
python testit.py
^
SyntaxError: invalid syntax
>>>
或者這樣:
>>> os.chdir("..")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'os' is not defined
>>>
我的建議是,打開一個Windows命令shell窗口cmd
命令,然後從那裏發出您的python myscript.py
。
如需更多幫助,查看您的代碼,至少會發生錯誤的前幾行以及某些確定python命令發佈位置的確定性會有所幫助。
你是說'os.chdir'和'os.getcwd'行在'myscript.py'中嗎? – robert
你在Python shell中輸入「python myscript.py」嗎? –
請向我們顯示確切的錯誤。 – robert