【发布时间】: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