- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在 Windows 上安装了 Python 2.7.1 和 2.6.5 版本。我在环境变量中只添加了 Python 2.6.5 的路径。现在,我想使用 Python 2.6.5 运行 Python 脚本 x.py
。我知道如何使用 cmd
执行此操作,但使用 IDLE 打开它并使用 Run Module
选项在其中运行会更方便。据推测,这是通过右键单击脚本,然后转到 Edit with IDLE
选项来完成的,但这会使用 Python 2.7.1 打开并运行脚本。有没有办法用 Python 2.6.5 打开和运行它?
最佳答案
Edit with IDLE
注册表中的标准命令如下:
"C:\Program Files\Python33\pythonw.exe" "C:\Program Files\Python33\Lib\idlelib\idle.pyw" -e "%1"
现在,如您所见,路径被硬编码到其中,所以它不能像那样使用不同的 Python 解释器——至少在默认情况下是这样。
然而,PEP 397为 Python 引入了一个新的 Python 启动器,可以启动基于 shebang 行的不同版本的 Python。因此,以 #!/usr/bin/env python2
开头的文件将启动当前的 Python 2 解释器,而 #!/usr/bin/env python3
将使用 Python 3 .
使用该信息,您可以为给定的 Python 版本动态启动 IDLE。例如,这将使用启动器的默认 Python 版本编辑文件:
C:\Windows\pyw.exe -m idlelib.idle -e "%1"
这将强制使用 Python 3
C:\Windows\pyw.exe -3 -m idlelib.idle -e "%1"
这将强制使用 Python 2:
C:\Windows\pyw.exe -2 -m idlelib.idle -e "%1"
所以你需要做的是编写一个脚本,基本上检查 哪个 文件想要执行的 Python 版本,即通过手动解析 shebang 行(遗憾的是启动器没有给你这个信息没有实际启动脚本——还没有。我可能会启动一个 pull request 来将这样的功能纳入核心)。然后您将使用上面的命令运行 Python 2 或 Python 3 IDLE 并完成。
您只需要更改 Edit with IDLE
命令即可执行您的脚本,然后它就可以工作了。
一个非常简单的替代方法是添加另一个启动 Python 2 IDLE 的注册表项。所以你会有 Edit with IDLE
和 Edit with IDLE (Py2)
之类的东西。
为此,只需将以下内容放入 .reg
文件并执行它:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell\Edit with IDLE (Py2)]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell\Edit with IDLE (Py2)\command]
@="C:\\Windows\\pyw.exe -2 -m idlelib.idle -e \"%1\""
编辑:我刚刚注意到我写这篇文章主要是关于 Python 2 与 Python 3;我认为启动器随 Python 2.7 一起提供,所以它的工作原理是一样的。您只需将启动器的版本指定器调整为 -2.6
和 -2.7
或您想要的任何版本。
关于python - 将 "Edit with IDLE"与 Python 2.6.5 脚本一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15343138/
我有 Site {{$url}} 和 $(function(){ $('#pencil').click
我在每一行都有一个编辑按钮,我已经设置了 defaultColDef: { editable: false, } 在网格选项中 当我点击编辑按钮时,我希望该行处于编辑模式。如果我设置
我在每一行都有一个编辑按钮,我已经设置了 defaultColDef: { editable: false, } 在网格选项中 当我点击编辑按钮时,我希望该行处于编辑模式。如果我设置
我有一个 html 文件,我想编辑其中的字段。以下是我的 html 代码: ID GROUP NAME GROUP DESCRIPTION IS A
我希望管理员能够编辑普通用户无法编辑的字段。例如作者或订阅者等。 我试过这个:Django admin: How to display a field that is marked as editab
如何将PS文件中间的数据移动到Mainframe的左侧?有什么快捷命令吗? 我有一个数据集,第 13 列有数据,必须将其移动到第 11 列,任何短键都可以移动它。 想要将 DS 中的其余行作为第一行对
我在 div 中有一个可编辑元素,它本身是可点击的。每当我单击 x-editable anchor 元素时,单击会在 DOM 中冒泡并触发对父 div 的单击。我怎样才能防止这种情况发生?我知道可以使
我有一个类似这样的模型: class Product(models.Model): third_party_id = models.CharField(max_length=64, blank
我有一个包含 2 个可编辑文本字段的页面 {{creator.name}} Tell us about yourself in less than 100 words
这是我的架构: id: 'EntryCode', fields: { EntryCode: {editable: true, validation: {required: true}, nul
有人可以帮助确定这个问题 - http://jsfiddle.net/xBB5x/8823/ 我正在尝试实现 x-editable (bootstrap 2) typeahead 功能。 上面的 js
如果我使用例如 g_object_set (renderer, "background", "red", "background-set", FALSE, NULL); 对于文本渲染器, TreeVi
我在创建和编辑页面上都使用了 Angular 文件,但我想知道是否有办法阻止用户在/edit 页面上编辑 Geo Segment 的名称。 geo-region-detail.html: G
我正在尝试向 QListWidget 添加一个项目,选择该项目,然后开始编辑新项目。 该项目被添加,它被选中,但该行没有被引入 QLineEdit,或者它试图使用的任何东西。 这是我的小部件的代码,相
我有一个表格,其中的单元格和列中有多个值。当用户单击 TD 单元格上的任意位置时,我希望它: 成为文本区域 将当前文本粘贴到文本区域 在其下方放置一个取消按钮 一旦按下取消按钮,我希望一切都变回以前的
在我的程序中,会有一个机会编辑框,它可以更改“掉率”或“获胜率” 但我想将其更改为如果用户输入大于 100 的数字并点击编辑框,编辑框文本将变回 100。 我不知道如何实现这个。 最佳答案 看看下面的
我想创建我的编辑表单,以便它将当前用户信息简单地显示为文本,而不是在文本字段中,当用户单击文本时,它将变成文本字段,用户可以编辑他的信息。仅当用户单击提交按钮时,更改才会反射(reflect)在数据库
我有一个 QTreeWidgetItem 添加到 QTreeWidget: QTreeWidgetItem* item = new QTreeWidgetItem(ui->trwPairs); ite
我检查了最新的 Dropbox 和 Excel for iOS。在 Dropbox 中,我们有一个编辑按钮。单击它会打开 Excel 的扩展程序,您可以在其中编辑文件。 保存后,更改也会反射(refl
我目前正在使用pycord创建一个Python语言的不和谐机器人。我有一个发送消息的命令,其中嵌入了两个字段。一个名为Yes,值为0;另一个名为No,值也为0。在选择菜单中,我创建了两个选项。选项是和
我是一名优秀的程序员,十分优秀!