2011-01-22 51 views
9

我想使用IRB來運行腳本,然後給我一個交互式提示。我在Python中使用python -i xy.py執行此操作,但在執行後退出irb xy.rbPython的IRB模擬-i

> python --help 

-i When a script is passed as first argument or the -c option is 
     used, enter interactive mode after executing the script or the 
     command 

回答

9
irb -r xy.rb 

它只是需要給你一個正常的IRB提示符之前提到的文件。

+4

請記住,使用'-r'或'require`不會讓您訪問腳本的局部變量,即使它們是在頂層執行環境中定義的。 – Kelvin 2013-01-29 16:44:57