经常运行规模小的python文件,打开ide又太慢,使用自带的编辑器运行一些小脚本就不错,有时候,Edit With Idle 不存在,手动添加注册表也麻烦,所以使用脚本生成注册表文件双击就能添加,希望能够方便到大家。
import subprocess
pythonw_path = subprocess.Popen("where pythonw", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='gbk').communicate()[0
idlepyw_path = pythonw_path[:-13]
pythonw_path = pythonw_path.replace('\\',r'\\').replace("\n","")
idlepyw_path = idlepyw_path.replace('\\',r'\\').replace("\n","")
#print(pythonw_path)
#print(idlepyw_path)
AddList = ["Windows Registry Editor Version 5.00\n\n",
"[HKEY_CLASSES_ROOT\SystemFileAssociations\.py]\n\n",
"[HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell]\n\n",
"[HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell\Edit with IDLE]\n\n",
"[HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell\Edit with IDLE\command]\n",
'@="\\"{}\\" \\"{}\\\Lib\\\idlelib\\\idle.pyw\\" \\"%1\\""'.format(pythonw_path,idlepyw_path)
]
with open("Edie_With_IDLE_双击添加.reg","w") as f:
f.writelines(AddList)