UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 166: illegal multibyte sequence
# -*- coding: utf-8 -*-
# encoding = utf-8
import unittest
import random class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
# 初始化一个递增序列
self.seq = range(10) def runTest(self):
# 从序列seq中随机选择一个元素
element = random.choice(self.seq)
# 验证随机元素是否确实属于列表中
self.assertIn(element, self.seq) class TestDictValueFormatFunctions(unittest.TestCase):
def setUp(self):
# 初始化一个递增序列,self.seq是个迭代器
self.seq = range(10)
self.lis = list(self.seq) def test_shuffle(self):
# 随机打乱原seq的顺序
random.shuffle(self.lis)
# 对打乱的seq进行升序排列
# sort(self.seq)
self.lis.sort()
# 验证重新排列后的seq时候和原seq序列一致
self.assertEqual(self.lis, list(range(10))) if __name__ == '__main__':
unittest.main() pycharm运行上述代码时,提示编码问题,因为代码中并没有中文,所以查看pycharm 的file encodings设置
file-》setting-》file encodings;把 Global Encoding、Project Encoding和下面的Default encoding for properties files 均设置成UTF-8,
最好file-》setting for new project也进行如上设置
最后,我运行的时候还是提示这个问题,再次新建了一个.py文件代码copy进去 再次运行,问题消失。

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 166: illegal multibyte sequence的更多相关文章
- Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal multibyte sequence
Python读取CSV文件,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 727: illegal mul ...
- python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence
python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal m ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 199: illegal multibyte sequence
=================================版权声明================================= 版权声明:原创文章 谢绝转载 请通过右侧公告中的“联系邮 ...
- 14 python读取文件时出现UnicodeDecodeError: 'gbk' codec can't decode byte 0xb7 in position 26: illegal multibyte sequence解决方法
>>> f = open("D:\\all.txt", "r")>>> f.read()Traceback (most re ...
- python3安装xadmin出现 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 3444: illegal multibyte sequence
python3的环境安装xadmin时,直接pip install xadmin出现 Downloading xadmin-0.6.1.tar.gz (1.0MB) 100% |███████████ ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence
最近对爬虫有点着迷, 在用bs4模块时,遇到报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illeg ...
- 【python】python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte sequence
python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence f ...
- python 读取文件时报错: UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence p ...
随机推荐
- day9面向对象,多线程2
一.获取全部qq成员头像 import os,requests,pymongo class Qqgroup(object):#定义一个类 #定义获取QQ群的请求rul,抓包获取 group_rul = ...
- Linux 内核参数 arp_ignore & arp_announce 详解
arp_ignore定义了对目标地址为本机IP的ARP询问的不同应答模式. arp_announce对网络接口(网卡)上发出的ARP请求包中的源IP地址作出相应的限制:主机会根据这个参数值的不同选择使 ...
- 201771010118《面向对象程序设计(java)》第三周学习总结
第一部分:理论知识复习部分 第一章 回顾了Java的关键术语,再次熟悉了java程序设计的性能介绍.对Java语言的十多种特性又有了更深刻的理解. 第二章 eclipse开发环境 ...
- HTML5_图片合成_刮刮卡
刮刮卡(图片合成) 定义: globalCompositeOperation 属性,设置或返回如何将源图像 将 myCanvas 的背景图设置为一张图片,(刮开后显示) // 目标图像(已有的,外面一 ...
- Hangover POJ - 1003
How far can you make a stack of cards overhang a table? If you have one card, you can create a maxim ...
- less 基础+ flex
1.less 中的变量 @ 符号 引入 /*普通变量*/ @color:pinker; .styles{ color:@color; } /*选择器变量*/ @I:img; @{I}{ width: ...
- C#获取项目程序及运行路径的方
1.asp.net webform用“Request.PhysicalApplicationPath获取站点所在虚拟目录的物理路径,最后包含“\”: 2.c# winform用 A:“Applic ...
- css----transition的应用,产生动画效果。
应用transition属性产生动画效果 css中的transition属性设置元素的变化过程所需的时间. <!DOCTYPE html> <html> <head> ...
- js, Date.parse firefox 兼容
Date.parse(dateVal); 这个方法很常用,parse() 方法可解析一个日期时间字符串,并返回 1970/1/1 午夜距离该日期时间的毫秒数. 可以验证输入日期是否窜在,不存在则返回N ...
- 初识Restful架构
1.对Rest(Restful)的理解 理解RESTful架构 怎样用通俗的语言解释REST,以及RESTful 维基百科:Representational state transfer 2.Rest ...