如何在Sublime Text 中為正在運行的程式啟用輸入
在Sublime Text 中,沒有內建的處理輸入的機制(例如,透過使用外部程式的Python 的raw_input()) 等函數。但是,有幾種解決方法可以促進輸入功能。
用於即時輸入的 SublimeREPL
SublimeREPL 是一個流行的 Sublime Text 插件,允許與正在運行的程式碼互動口譯員。它提供將輸入即時傳遞給正在運行的程式的功能。請依照以下步驟使用 SublimeREPL:
- 使用 Package Control 安裝 SublimeREPL。
- 設定 Main.sublime-menu 檔案以確保您的首選解釋器正確運作。
- 按Ctrl Enter 開啟REPL 面板並與
用於獨立互動的自訂建置系統
如果SublimeREPL 不能滿足您的需求,建立自訂建置系統可以讓您獨立運行您的程序,並且處理輸入。
Windows 建置系統:
{ "cmd": ["start", "cmd", "/k", "path/to/python.exe", "$file"], "selector": "source.python", "shell": true, "working_dir": "$file_dir", "env": {"PYTHONIOENCODING": "utf-8"} }
將「path/to/python.exe」取代為 Python 執行檔的路徑。按 Ctrl B 在新的 cmd 視窗中建置並執行您的程式。
macOS 建置系統:
{ "shell_cmd": "osascript -e 'tell app \"Terminal\" to do script \"cd $file_path & python3 -u $file\"'", "working_dir": "$file_path", "selector": "source.python", "env": {"PYTHONIOENCODING": "utf-8"} }
指定您的 Python 執行檔(如果它不在您的 $ 上)小徑。運行建置系統會在終端機視窗中開啟程式。
Linux 建置系統:
{ "shell_cmd": "gnome-terminal --working-directory=$file_path -- bash -c 'python3 -u \"$file\" & read -n 1 -s -r'", "working_dir": "$file_path", "selector": "source.python", "env": {"PYTHONIOENCODING": "utf-8"} }
程式運作完畢後按任意鍵關閉終端視窗.
增強型終端互動
Terminus是一個多功能插件,為管理輸入提供了全面的解決方案。它提供了一個圖形介面,用於透過建立面板與正在運行的程式進行交互,從而無需自訂建置系統。使用 Package Control 安裝 Terminus 並建立以下建置系統:
{ "target": "terminus_exec", "cancel": "terminus_cancel_build", "cmd": [ "/path/to/python", "-u", "$file" ], "working_dir": "$file_path", "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)&" }
根據其文件配置 Terminus 以利用其高級功能。
透過實作這些解決方法,您可以有效地使用輸入,同時在 Sublime Text 中執行外部程序,以實現更全面的編碼體驗。
以上是在 Sublime Text 中執行外部程式時如何處理輸入?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

pythonuseshybridapprace,ComminingCompilationTobyTecoDeAndInterpretation.1)codeiscompiledtoplatform-Indepententbybytecode.2)bytecodeisisterpretedbybythepbybythepythonvirtualmachine,增強效率和通用性。

theKeyDifferencesBetnewpython's“ for”和“ for”和“ loopsare:1)” for“ loopsareIdealForiteringSequenceSquencesSorkNowniterations,而2)”,而“ loopsareBetterforConterContinuingUntilacTientInditionIntionismetismetistismetistwithOutpredefinedInedIterations.un

在Python中,可以通過多種方法連接列表並管理重複元素:1)使用 運算符或extend()方法可以保留所有重複元素;2)轉換為集合再轉回列表可以去除所有重複元素,但會丟失原有順序;3)使用循環或列表推導式結合集合可以去除重複元素並保持原有順序。

fasteStmethodMethodMethodConcatenationInpythondependersonListsize:1)forsmalllists,operatorseffited.2)forlargerlists,list.extend.extend()orlistComprechensionfaster,withextendEffaster,withExtendEffers,withextend()withextend()是extextend()asmoremory-ememory-emmoremory-emmoremory-emmodifyinginglistsin-place-place-place。

toInSerteLementIntoApythonList,useAppend()toaddtotheend,insert()foreSpificPosition,andextend()formultiplelements.1)useappend()foraddingsingleitemstotheend.2)useAddingsingLeitemStotheend.2)useeapecificindex,toadapecificindex,toadaSpecificIndex,toadaSpecificIndex,blyit'ssssssslorist.3 toaddextext.3

pythonlistsareimplementedasdynamicarrays,notlinkedlists.1)他們areStoredIncoNtiguulMemoryBlocks,mayrequireRealLealLocationWhenAppendingItems,EmpactingPerformance.2)LinkesedlistSwoldOfferefeRefeRefeRefeRefficeInsertions/DeletionsButslowerIndexeDexedAccess,Lestpypytypypytypypytypy

pythonoffersFourmainMethodStoreMoveElement Fromalist:1)刪除(值)emovesthefirstoccurrenceofavalue,2)pop(index)emovesanderturnsanelementataSpecifiedIndex,3)delstatementremoveselemsbybybyselementbybyindexorslicebybyindexorslice,and 4)

toresolvea“ dermissionded”錯誤Whenrunningascript,跟隨台詞:1)CheckAndAdjustTheScript'Spermissions ofchmod xmyscript.shtomakeitexecutable.2)nesureThEseRethEserethescriptistriptocriptibationalocatiforecationAdirectorywherewhereyOuhaveWritePerMissionsyOuhaveWritePermissionsyYouHaveWritePermissions,susteSyAsyOURHomeRecretectory。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver Mac版
視覺化網頁開發工具

Dreamweaver CS6
視覺化網頁開發工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。