在sublime中直接运行python代码
系統:win10
編輯器:sublime TXT 3
---------------------------------
?
有兩種方法可以在sublime中直接運行python代碼。
1)非交互式程序寫完代碼保存后直接按ctrl+B,如只有輸出的程序。
2)交互式程序需要下載SublimeREPL,如需要輸入的的程序。
?
1. 非交互式程序
1)設置:
工具(tool)-->編譯系統(build-system)-->設置為自動,或者直接選擇python
2)編輯代碼
print("hello python.")
保存為test.py
3)執行
按ctrl+B,可在sublime界面下方彈出結果。
注:確保已經正確配置好python的環境變量(PATH)
?
2. 交互式環境
準備代碼,保存為test.py
msg = input("please input: ")
print("output: ", msg)
1)按ctrl+shift+p快捷鍵呼出一個輸入框,輸入Install Package,回車,在新出現的輸入框里輸入SublimeREPL安裝。
2)點擊Tools->sublimeREPL->python->python run current file,這時候就像IDLE一樣,會彈出一個新的窗口,而且是可交互的,可以輸入。
3)結果:
4)設置快捷鍵
點擊preferences->key bindings
添加:
{ "keys":["f5"],"caption": "SublimeREPL: Python - RUN current file","command": "run_existing_window_command","args": {"id": "repl_python_run","file": "config/Python/Main.sublime-menu"}}重啟sublime,現在可以直接按F5來運行。
?
總結
以上是生活随笔為你收集整理的在sublime中直接运行python代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 资产配置模型之-BL模型
- 下一篇: python画交互式地图_使用Pytho