# -*- 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. laravel之模型Model

    模型Model: 在控制器中调用:

  2. php正则表达式 剔除字符串中 ,除了汉字的字符(只保留汉字) php 正则 只保留汉字,剔除所有符号

    <?php //提取字符串中的汉字其余信息剔除 $str='f龙,真 .,.,.?!::·…~&@#,.?!:;.……-&@#“”‘’〝 "〞'´'>< ...

  3. 2018-2019-2 20175320实验二《Java面向对象程序设计》实验报告

    2018-2019-2 20175320实验二<Java面向对象程序设计>实验报告 一.实验步骤及内容 (一)了解使用JUint,并对示例代码MyUtil进行测试 1.先在IDEA中安装J ...

  4. 【Python基础】lpthw - Exercise 44 继承与组合

    一.继承 原则:大部分使用继承的场合都可以用组合取代或者简化,而多重继承则需要不惜一切的避免. 1. 什么是继承 继承:用于指明一个类的大部分或者全部功能都是从一个父类获得的.此时,父类的实例的所有动 ...

  5. Linux使用pam_tally2.so模块限制登录失败锁定时间

    关于PAM Linux-PAM (Pluggable Authentication Modules for Linux)可插拔认证模块. https://www.cnblogs.com/klb561/ ...

  6. 判断为false的情况

    console.log(''==false)  //true console.log('0' == false)  //true console.log(null == false) //false, ...

  7. eclipse安装使用fat打jar包

    在线安装步骤: eclipse菜单栏 help >software updates >Search for new features to install>new update si ...

  8. JS 全选

    第一种情况 1. 首先得有全选  checkall <input type="checkbox" class="checkAll" value=" ...

  9. gitlab自动备份和定时删除

    GitLab数据手动备份1.GitLab默认备份目录为/var/opt/gitlab/backups,可以修改/etc/gitlab/gitlab.rb里面的默认存放备份文件目录,这里使用默认备份目录 ...

  10. group by分组后获得每组中符合条件的那条记录

    当group by单独使用时,只显示出每组的第一条记录.如下,未分组时查询出两条记录 SELECT info.id, info.switch_id, info.port_id, info.mac_ad ...