sublime编辑模式下,编译py文件,enter键后并没有打印,发现是sublime编译方式的问题,需要安装插件sublimeREPL。

#!/usr/bin/python3
str = input("请输入: ")
print(str)

python 换行输入 python换行输入不运行_Python

安装完之后,点击tool--sublimeREPL-- Python-- Python - RUN current file,就可以正常的编译,输入一行后打印

python 换行输入 python换行输入不运行_f5_02

由于每次编译都需要这步操作,会很麻烦,可以设置快捷键:

点击Preferences--key Bindings,设置快捷键,本次设置的是f5,可以自行修改

python 换行输入 python换行输入不运行_f5_03

[
{"keys": ["f5"],"command": "repl_open",
"caption": "Python - RUN current file",
"id": "repl_python_run",
"mnemonic": "R",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["python", "-u", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]