2011-01-22 23 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