sublime text3和Python3的配置记录

分屏键为Alt+Shift+数字


新建一个sublime build system

这里写图片描述

然后自动打开了一个文本,清空并写入以下内容:

{
    "env": {"PYTHONIOENCODING": "utf8"},
    "cmd": ["C:/Users/sen/AppData/Local/Programs/Python/Python35/python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

“env”: {“PYTHONIOENCODING”: “utf8”}, 是避免中文报错!

[“C:/Users/sen/AppData/Local/Programs/Python/Python35/python.exe”, “-u”, “$file”], 这里路径要替换成你电脑中python3的路径。

保存文件名为python3.sublime-build


ctrl + shift + p输入Package Control点击Install Package


然后输入sublimeREPL,稍候一阵底部就会告诉你安装好了。


Prefereces -> key Bindings 

输入代码 

[ 
    {
    	"keys": ["f4"], 
        "caption": "SublimeREPL: Python3 - RUN current file",
		"command": "run_existing_window_command",
		"args":
		{
			"id": "repl_python3_run",
			"file": "config/Python3/Main.sublime-menu"
		}
	}
]


注意:每个键设置都在各自的花括号内,花括号内以逗号隔开各个语句;不同键之间也以逗号隔开。
"key": 为设置的快捷键对应的按键,第一个为F4,组合快捷键以“+”衔接,如 ["alt+p"]
"command": 为一段键的说明,可自定义。
"args":  "id"为配置文件"file"内对应的ID,具体由对应的配置文件决定

Packages:Browse Package 找到 SublimeREPL的文件夹,再进入config文件夹,可以看到许多语言的配置文件,Python也在里面

在这里新建一个Python3的文件夹,在里面新建Default.sublime-commands和Main.sublime-menu两个文件(模仿Python文件夹)

Default.sublime-commands配置如下:

[
    {
		"caption": "SublimeREPL: Python3",
		"command": "run_existing_window_command", "args":
		{
			"id": "repl_python3",
			"file": "config/Python3/Main.sublime-menu"
		}
	},
	{
		"caption": "SublimeREPL: Python3 - RUN current file",
		"command": "run_existing_window_command", "args":
		{
			"id": "repl_python3_run",
			"file": "config/Python3/Main.sublime-menu"
		}
	}
]


Main.sublime-menu配置如下:

[
	{
		"id": "tools",
		"children":
		[{
			"caption": "SublimeREPL",
			"mnemonic": "R",
			"id": "SublimeREPL",
			"children":
			[
				{"caption": "python3",
				"id": "python3",				 
				"children":[
					{"command": "repl_open",
					"caption": "python3",
					"id": "repl_python3",
					"mnemonic": "P",
					"args": {
						"type": "subprocess",
						"encoding": "utf8",
						"cmd": ["C:/Users/sen/AppData/Local/Programs/Python/Python35/python.exe", "-i", "-u"],
						"cwd": "$file_path",
						"syntax": "Packages/Python/Python.tmLanguage",
						"external_id": "Python3",
						"extend_env": {"PYTHONIOENCODING": "utf-8"}
					}
					},
					{"command": "repl_open",
					"caption": "python3 - RUN current file",
					"id": "repl_python3_run",
					"mnemonic": "R",
					"args": {
						"type": "subprocess",
						"encoding": "utf8",
						"cmd": ["C:/Users/sen/AppData/Local/Programs/Python/Python35/python.exe", "-u", "$file_basename"],
						"cwd": "$file_path",
						"syntax": "Packages/Python/Python.tmLanguage",
						"external_id": "Python3",
						"extend_env": {"PYTHONIOENCODING": "utf-8"}
					}
					}
				]}
			]
		}]
	}
]


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值