# -*- 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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 199: illegal multibyte sequence

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  请通过右侧公告中的“联系邮 ...

  4. 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 ...

  5. 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% |███████████ ...

  6. 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 ...

  7. 【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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. hadoop2集群环境搭建

    在查询了很多资料以后,发现国内外没有一篇关于hadoop2集群环境搭建的详细步骤的文章. 所以,我想把我知道的分享给大家,方便大家交流. 以下是本文的大纲: 1. 在windows7 下面安装虚拟机2 ...

  2. Linux系统(和mac系统)chmod修改权限总结

    在 Mac 系统的终端上修改文件权限使用的是 Linux 中的 chmod 命令. chmod 用户+操作+权限+文件 用户部分:使用字母 u 表示文件拥有者(user),g 表示拥有者所在群组(gr ...

  3. Servlet.service() for servlet [jsp] in context with path [/Healthy_manager] threw exception [Unable to compile class for JSP] with root cause java.lang.IllegalArgumentException: Page directive: inval

    严重: Servlet.service() for servlet [jsp] in context with path [/Healthy_manager] threw exception [Una ...

  4. 转载Alpine Linux常用命令

    Alpine Linux常用命令 目录 一:Alpine Linux开启SSH远程登陆 1.简介: 2.配置 3.配置命令 4.重启服务 二:Alpine Linux源管理 1.简介 2.国内源简介: ...

  5. 三类设计模式UML图

    http://design-patterns.readthedocs.org/zh_CN/latest/index.html

  6. 使用ajax分页查询

    controller: /** * 查询所有用户/查找指定用户 * 分页+搜索 * */@RequestMapping("/findClientBySize")@ResponseB ...

  7. PHP 利用CURL(HTTP)实现服务器上传文件至另一服务器

    // 上传端 /** * 向目标地址推送xls文件 * @Date 2019/4/29 */ public function putXls() { // 目标接口 $url = "http: ...

  8. sublime 将tab替换为4个空格 & 显示空格

    preferences -> settings -> 在右侧的json中加入(左侧的默认配置是无法修改的,可以在默认配置中搜到这几个配置) // The number of spaces ...

  9. FSPageContentView这个库需要修改源码才能用,否则有黑屏bug

    去掉 - (instancetype)initWithFrame:(CGRect)frame childVCs:(NSArray *)childVCs parentVC:(UIViewControll ...

  10. WinAPI 字符及字符串函数(9): lstrcat - 合并字符串

    unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...