如何在Notepad++中执行Python文件?

2024-04-19 05:14:19 发布

您现在位置:Python中文网/ 问答频道 /正文


Tags: python
3条回答

@Ramiz Uddin's answer绝对值得更多关注:

  • 打开记事本++
  • 在菜单上转到:运行运行。。(F5)
  • 键入:cmd /K python "$(FULL_CURRENT_PATH)"

第一个选项:(最简单,推荐)

打开记事本++。在菜单上转到:运行->;运行。。(五楼)。键入:

C:\Python26\python.exe "$(FULL_CURRENT_PATH)"

现在,不要按run,而是按save为它创建快捷方式。

注释

  • 如果您有Python 3.1:输入Python31,而不是Python26
  • 如果希望脚本完成后命令行窗口保持打开状态,请添加-i

第二个选项

使用运行Python脚本的批处理脚本,然后从Notepad++创建该脚本的快捷方式。

如前所述:http://it-ride.blogspot.com/2009/08/notepad-and-python.html


第三种选择:(不安全)

The code opens “HKEY_CURRENT_USER\Software\Python\PythonCore”, if the key exists it will get the path from the first child key of this key.

检查此密钥是否存在,如果不存在,则可以尝试创建它。

以下是对我有用的:

打开记事本+,然后按F5。你会看到一个弹出框:

Pop up box for entering the program to run

Type: C:\Python27\python.exe -i "$(FULL_CURRENT_PATH)" for Python 2.7.

and then Save As..., and pick your own key combo to start it each time you want to run something

相关问题 更多 >