当我尝试保存带有特定注释的文件时,Python IDLE 拒绝保存并且崩溃

标签 python python-2.7 crash save comments

我正在运行 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/

相关文章:

python - query_set 中的 values_list() 只显示数字而不显示国家名称

python - python 中 __truediv__ 的运算符重载

python - 如何在多个字典列表中对字典的每个值实现模糊搜索?

iphone - Xcode显示未知字符

python - 如何使用 Azure Cloud Function (python) 中的用户管理身份向 Azure KeyVault 发出请求?

python - spy : how to make completion and documentation pop-up windows appear only on command

javascript - 将 MySQL 查询结果传递给 Django 中的 Javascript/Jquery

python - 如何? : Setting up Bokeh w/Redis Backend

iOS 7 应用程序崩溃 EXC_CRASH (SIGABRT) objc_exception_throw 在 iOS 6 上工作正常

Swift 3 - [__NSArrayM objectAtIndex :]: index 3 beyond bounds [0 . 。 2]