[問題] 初學者想請問路徑的問題

看板Python作者 (笑得很勉強)時間14年前 (2011/01/26 13:19), 編輯推噓3(3012)
留言15則, 5人參與, 最新討論串1/1
我的作業系統是XP Python是去抓官方網站的3.1來裝 然後用命令列的方式來執行 閱讀的網站是良葛格的http://caterpillar.onlyfun.net/Gossip/Python/index.html 我在做到http://caterpillar.onlyfun.net/Gossip/Python/ModuleABC.html 網頁時 跟著網站上輸入python hello.py Python卻回傳 File "<stdin>", line 1 Python hello.py ^ SyntaxError: invalid syntax 後來我搜尋到這個網站http://pydoing.blogspot.com/2010/11/python-pathset.html 並根據網站中給的路徑設定來設定 但是結果還是一樣 請問我該如何解決這個問題呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.170.56

01/26 14:08, , 1F
你的命令列是指IDLE還是CMD
01/26 14:08, 1F

01/26 14:38, , 2F
你的hello.py的內容是?
01/26 14:38, 2F

01/26 15:15, , 3F
命令列是安裝完之後所有程式中的Python (command line)
01/26 15:15, 3F

01/26 15:16, , 4F
hello.py的內容是print('Hello!Python!')
01/26 15:16, 4F

01/26 17:18, , 5F
命令列應該是用 CMD
01/26 17:18, 5F

01/26 20:09, , 6F
把 python/lib 也加到路徑看看
01/26 20:09, 6F

01/26 23:21, , 7F
Python (command line) 是讓你執行程式而不是讓你執行檔案
01/26 23:21, 7F

01/26 23:22, , 8F
舉例來說,你在 Python (command line) 可以打
01/26 23:22, 8F

01/26 23:24, , 9F
print('Hello')
01/26 23:24, 9F

01/26 23:24, , 10F
這樣你就會看到螢幕輸出 Hello
01/26 23:24, 10F

01/26 23:25, , 11F
你把 print('Hello') 寫在 hello.py 這個檔案存到 C:\ 後
01/26 23:25, 11F

01/26 23:26, , 12F
你可以在電腦裡找到一個叫 cmd.exe 的檔案,執行他
01/26 23:26, 12F

01/26 23:27, , 13F
打 cd\ ,切換到當前目錄到 C:\
01/26 23:27, 13F

01/26 23:27, , 14F
再打 python hello.py,就可以看到螢幕輸出 Hello
01/26 23:27, 14F

01/27 00:16, , 15F
喔喔!瞭解了~謝謝你 :))))))
01/27 00:16, 15F
文章代碼(AID): #1DFwxwGM (Python)
文章代碼(AID): #1DFwxwGM (Python)