Geany默认编码为GBK,使用其运行unittest时提示Non-UTF-8 code starting with ‘\xd5‘该如何解决?

在使用Geany编辑器运行Python的unittest时遇到非UTF-8编码错误,具体表现为'xd5'开头的GBK编码无法识别。为了解决此问题,需要确定并修改设置,使Geany以UTF-8编码读取和保存文件。
摘要由CSDN通过智能技术生成

使用的Python编辑器为Geany
survey.py的代码如下:

# -*- coding: GBK -*-
class AnonymousSurvey():
	"""收集匿名调查问卷的答案"""
	
	def __init__(self,question):
		"""存储一个问题,并为存储答案做准备"""
		self.question = question
		self.responses = []
		
	def show_question(self):
		"""显示调查问卷"""
		print(self.question)
		
	def store_response(self, new_response):
		"""存储单份调查问卷"""
		self.responses.append(new_response)
		
	def show_results(self):
		"""显示收集到的所有答卷"""
		print("Survey results: ")
		for response in self.responses:
			print('- ' + response)

test.survey.py的代码如下:

import unittest
from survey import AnonymousSurvey

class TestAnonymousSurvey(unittest.TestCase):
	"""针对该类的测试"""
	
	def test_store_single_response(self):
	
		question = "What language did you first learn to spe
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值