我正在运行 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.
我想有一些我不知道的评论规则,所以任何见解将不胜感激。
最佳答案
您必须进入选项 -> 配置 IDLE -> 常规并将默认源编码设置为 UTF-8 选项。
关于当我尝试保存带有特定注释的文件时,Python IDLE 拒绝保存并且崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37759950/