本文介绍了如何在 Sublime Text 3 中运行 python 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的设备 (Windows) 中安装了 python 3.5 解释器.

I have installed the python 3.5 interpretor in my device (Windows).

任何人都可以指导我使用包来像 SublimeREPL 一样运行它吗?

Can anybody guide me through the process of using packages to run it like SublimeREPL?

推荐答案

是的,你可以使用任何想要从 Sublime 运行程序的 Python 版本——你只需要定义一个新的 构建系统.选择 Tools ->构建系统 ->新建构建系统,然后删除其内容并替换为:

Yes, you can use any Python version you want to run programs from Sublime - you just need to define a new build system. Select Tools -> Build System -> New Build System, then delete its contents and replace it with:

{
    "cmd": ["C:/Python35/python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

假设 C:/Python35/python.exe 是正确的路径.如果 python.exe 位于其他地方,只需放入正确的路径,使用正斜杠 / 而不是 Windows 标准的反斜杠 \.

assuming that C:/Python35/python.exe is the correct path. If python.exe resides someplace else, just put in the correct path, using forward slashes / instead of the Windows standard backward slashes \.

将文件另存为Packages/User/Python3.sublime-build,其中Packages 是通过选择Preferences -> 打开的文件夹;浏览包... - Sublime 应该已经自动将其保存在正确的目录中.现在,将会有一个 Tools ->构建系统 ->Python3 选项,您可以选择该选项以使用 Python 3 运行文件.

Save the file as Packages/User/Python3.sublime-build, where Packages is the folder opened by selecting Preferences -> Browse Packages... - Sublime should already automatically save it in the right directory. Now, there will be a Tools -> Build System -> Python3 option that you can select for running files with Python 3.

有关使用 Python 3 设置 SublimeREPL 的详细信息,请按照我在此处的回答中的说明进行操作.

For details on setting up SublimeREPL with Python 3, please follow the instructions in my answer here.

这篇关于如何在 Sublime Text 3 中运行 python 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 11:04