sublimetext无法对input或者raw_input执行。因此搜了很多方法后,解决了这个问题:
1.先下载插件sublimerepl ,如果无法下载,请点击https://github.com/wuub/SublimeREPL下载后放在本地文件下:
![](https://i-blog.csdnimg.cn/blog_migrate/4ea33f037024773071a368b47064a556.png)
2.下打开 ..\Sublime Text 3\Data\Packages\SublimeREPL\config\Python目录下的Main.sublime-menu文件,找到"id": "repl_python"所在行,将这个JSON对象中args属性下cmd属性值改为["python", "-i", "-u", "$file_basename"],如图所示:
![](https://i-blog.csdnimg.cn/blog_migrate/70e454aede69dc5c325dff239e70809e.png)
*你可以改为["python", "-i", "-u", "$file_basename"],我的电脑上有两个版本的python,所以我这里有个python3
3.重启sublimeTEXT,进行快捷键配置:
首选项->按键绑定-用户,然后在弹出的文件中输入:
![](https://i-blog.csdnimg.cn/blog_migrate/5ec2057ad9fe3152cffe07839b03e764.png)
[{ "keys":["f5"],"command":"repl_open", "caption":"Python", "mnemonic":"p", "args":{ "type":"subprocess", "encoding":"utf8", "cmd":["python3","-i", "-u", "$file"], "cwd":"$file_path", "syntax":"Packages/Python/Python.tmLanguage", "external_id":"python" }}]
ctrl+s保存,然后试运行代码"
a=input("a:")
如果成功,那么效果是这样的:
![](https://i-blog.csdnimg.cn/blog_migrate/386d035ab36a2d9f0f38b9505400ccdc.png)
好了,解决了!
顺便提一下
如果你也喜欢Python 这里有一群Python爱好者汇集在此。
关注微信公众号:【软件测试技术】,回复 888,获取QQ群号。