【问题标题】:Python IDLE is refusing to save and is the crashing when I try to save a file with a specific comment当我尝试保存带有特定注释的文件时,Python IDLE 拒绝保存并且崩溃
【发布时间】:2016-06-11 04:32:39
【问题描述】:

我正在运行 Python 2.7。我在 IDLE 中写了一些代码。我发现它不会保存文件。如果我反复尝试保存,IDLE 就会完全崩溃。我发现如果我删除以下评论,它会保存:

#Add a fourth parameter, end, to the find function that specifies where to stop looking. Warning: This exercise is a bit tricky. The default value of end should be len(str), but that doesn't work. The default values are evaluated when the function is defined, not when it is called. When find is defined, str doesn't exist yet, so you can’t find its length.

奇怪的是,我发现如果我将评论截断为以下内容,它可以保存:

#Add a fourth parameter, end, to the find function that specifies where to stop looking. Warning: This exercise is a bit tricky. The default value of end should be len(str), but that doesn

好像不是评论的长度,因为这个版本,评论一分为二,也不保存:

#Add a fourth parameter, end, to the find function that specifies where to stop looking. Warning: This exercise is a bit tricky. The default value of end should be len(str), but that doesn
#’t work. The default values are evaluated when the function is defined, not when it is called. When find is defined, str doesn’t exist yet, so you can’t find its length.

我想有一些我不知道的 cmets 规则,所以任何见解都将不胜感激。

【问题讨论】:

  • 尝试使用其他文本编辑器。看看问题是否仍然存在。我推荐 SublimeText3
  • 谢谢。我将来可能会这样做,但我现在的目标是找出这里出了什么问题。
  • 随意追鬼。你在窗户上吗?您可能需要重新安装 python。应该安装新版本的 IDLE ......很多年没有使用 IDLE,那里只有更好的编辑器......
  • 如果您将代码保存在带有 .py 扩展名的记事本中,您应该能够在 IDLE 中打开它并继续编辑和保存,而不会出现任何问题。

标签: python python-2.7 crash save comments


【解决方案1】:

你必须进入 Options -> Configure IDLE -> General 并将 Default Source Encoding 设置为 UTF-8 选项。

【讨论】:

  • 该选项似乎不存在
【解决方案2】:

重新启动计算机后重试。

如果未解决请尝试访问

https://bugs.python.org/issue14996

【讨论】:

  • 感谢您的想法。我尝试重新启动。没有骰子。我看了看票。不幸的是,他们遇到的问题似乎与保存到的目录有关,而不是文件的内容。似乎也没有任何修复(不适用于该用户)在这里工作。
【解决方案3】:

我的问题和你一模一样。我发现在您输入超过 10 个字符并保存后,显然 IDLE 重载或某种类型。每次我写一个单词时,我都会尝试保存 Ctrl+S,这似乎是它能够保存的唯一方法。如果您发现任何其他解决问题的方法,请务必通知!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-20
    相关资源
    最近更新 更多