用sublime写了python3的代码,COMMAND + B运行调用 PYTHON3
我们先来新建一个sublime build system
然后自动打开了一个文本,清空并写入以下内容:
{
"env": {"PYTHONIOENCODING": "utf8"},
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.6/bin/python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
“env”: {“PYTHONIOENCODING”: “utf8”}, 是避免中文报错!
[“/Library/Frameworks/Python.framework/Versions/3.6/bin/python3”, “-u”, “$file”], 这里路径要替换成你电脑中python3的路径。
查看python3的路径
$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
然后,保存文件名为python3.sublime-build
接着,选择python3
我们来验证以下,当前版本是不是python3
import sys
print(sys.version)
按COMMANDl + B 运行,结果如下
3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
[Finished in 0.1s]
OVER