SyntaxError: Non-UTF-8 code starting with '\xcd' in file
时间: 2023-12-21 22:02:25 浏览: 194
这个错误是Python中的一个语法错误,表示在文件中发现了一个以非UTF-8编码开头的字符。解决这个错误的方法有几种。一种方法是在代码的开头添加 # -*- coding:utf-8 -*- 或者 # coding=gbk 这样的语句来指定文件的编码方式。另一种方法是修改文件的编码方式。可以通过编辑器的设置来临时修改文件的编码,或者修改默认文件编码以解决该问题。例如,在Geany编辑器中,可以通过选择"文件Document",然后选择"设置文件编码Set Encoding",并将编码格式设置为"Unicode UTF-8"来临时修改文件的编码。另外,还可以通过选择"编辑Edit",然后选择"首选项Preferences",在"编码Encoding"中将"默认编码格式(新文件)Default encoding(new file)"设置为"Unicode UTF-8"来修改默认文件编码。希望这些方法能帮助您解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [SyntaxError: Non-UTF-8 code starting with ‘\xcd‘ in file D:\E\pythoncode\pachongDemo\demo.py on ...](https://blog.csdn.net/qq_35367566/article/details/114316321)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Python错误: SyntaxError: Non-ASCII character解决办法](https://download.csdn.net/download/weixin_38644097/12872950)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [[Python解决方法]SyntaxError: Non-UTF-8 code starting with '\xcb' in file test1.py on line](https://blog.csdn.net/LearnLittleGenius/article/details/102097914)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文