![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Alvin'sWay
立此博客,与君共勉
展开
-
【Python】错误:Command python setup.py egg_info failed with error code 1 in ...
错误:Command "python setup.py egg_info" failed with error code 1 in/tmp/pip-build-5id41kwd/matplotlib/1. 错误描述:执行指令pip install matplotlib输出错误信息 Complete output from command python setup.py egg_info: Traceback (most recent call last): Fi.原创 2020-06-06 18:00:32 · 891 阅读 · 0 评论 -
【Python】错误:TypeError: the JSON object must be str, not bytes
错误:TypeError: the JSON object must be str, not 'bytes'错误信息:TypeError: the JSON object must be str, not 'bytes'错误原因:data = json.loads(download_page(url).content)['data']解决方法:data = json.loads(download_page(url).content.decode())['data']...原创 2020-06-03 16:52:34 · 733 阅读 · 0 评论 -
【Python】UnicodeDecodeError: gbk codec can not decode byte 0xa7 in position 8: illegal multibyte
错误: UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 8: illegal multibyte错误信息:UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 8: illegal multibyte 错误原因:with open('space list.txt', 'r') as f: for line in f.原创 2020-06-03 16:46:57 · 1028 阅读 · 0 评论 -
【Python】Python中两个列表元素排序后保持对应关系
Python中两个列表元素排序后保持对应关系功能介绍例如:list_a=[1,5,2,3],list_b=[2,3,1,4]保持下标对应,即 lsit_a中 1 对应 list_b中 2,以此类推,list_a升序后 list_sort=[1, 2, 3, 5],lsit_sort中 1 对应 2 这一关系仍保持不变示例代码list_a=[1,5,2,3]list_b=...原创 2020-05-03 14:34:15 · 2485 阅读 · 1 评论 -
【Python】错误: AttributeError: 'list' object has no attribute 'sorted'
错误: AttributeError: 'list' object has no attribute 'sorted'错误信息:AttributeError: 'list' object has no attribute 'sorted'错误原因:list_a=[1,5,2,3]list_b=[2,3,1,4]list_sort=sorted()print("list...原创 2020-05-03 14:12:21 · 2596 阅读 · 0 评论 -
【Python】设置numpy
设置numpy查看numpy相关信息pip show numpy安装指定版本的numpypip install -U numpy==1.16.0卸载numpypip uninstall numpy原创 2020-04-29 16:48:20 · 176 阅读 · 0 评论 -
【Pthon】Python 条件语句
Python 条件语句注:python 不支持switch语句形式if 判断条件1: 执行语句1……elif 判断条件2: 执行语句2……elif 判断条件3: 执行语句3……else: 执行语句4……实例test_num=10if test_num > 10: print('> 10')elif test_n...原创 2020-04-29 12:11:25 · 112 阅读 · 0 评论 -
【Python】Python enumerate() 函数
Python enumerate() 函数函数原型enumerate(iterable,start=0)参数iterable— —必须是一个序列,或iterator,或其他支持迭代的对象。start— —下标起始位置返回值返回一个枚举对象。enumerate()返回的迭代器的__next__()方法返回一个元组,里面包含一个计数值(从start开始,...原创 2020-04-29 10:11:49 · 353 阅读 · 0 评论 -
【Python】错误:AttributeError: module 'tensorflow' has no attribute 'placeholder'
错误:AttributeError: module 'tensorflow' has no attribute 'placeholder'错误信息:AttributeError: module 'tensorflow' has no attribute 'placeholder'错误原因:TensorFlow 2中使用TensorFlow 1中的API解决方法:impo...原创 2020-04-28 20:25:21 · 2408 阅读 · 0 评论 -
【Python】错误:ERROR: markdown 3.1.1 has requirement setuptools>=36, but you’ll have setuptools 20.7.0 w
错误:ERROR: markdown 3.1.1 has requirement setuptools>=36, but you’ll have setuptools 20.7.0 w错误信息:ERROR: markdown 3.1.1 has requirement setuptools>=36, but you’ll have setuptools 20.7.0 w错...原创 2020-04-28 20:21:10 · 989 阅读 · 0 评论 -
【Python】错误:ModuleNotFoundError: No module named 'PIL'
错误:ModuleNotFoundError: No module named 'PIL'导入模块:import PIL错误信息:ModuleNotFoundError: No module named 'PIL'错误原因:为安装模块PIL解决方法:pip install pillow...原创 2020-04-28 09:50:47 · 1009 阅读 · 2 评论 -
【Python】Python os.listdir() 方法
Python os.listdir() 方法1. 概述os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。它不包括.和..即使它在文件夹中。只支持在 Unix, Windows 下使用。2. 语法os.listdir(path)参数:path - -需要列出的目录路径返回值:返回指定路径下的文件和文件夹列表3...原创 2020-04-25 22:41:41 · 980 阅读 · 0 评论 -
【Python】python中如何注释
python中如何注释1.单行注释#单行注释print("Hello");2.多行注释使用单引号'''多行注释多行注释多行注释'''print("Hello");使用多引号"""多行注释多行注释多行注释"""print("Hello");...原创 2020-04-21 21:46:49 · 217 阅读 · 0 评论 -
【python】Sublime Text3 中配置opencv
Sublime Text3 中配置opencv1、下载python版本对应的opencv库官方网址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv例如:contrib:contrib库cp35:python版本win32:32位win_amd64:64位2、安装opencv库pip insta...原创 2019-06-28 20:49:07 · 1811 阅读 · 0 评论 -
【python】错误:UnboundLocalError: local variable 'XXX' referenced before assignment
1、错误:UnboundLocalError: local variable 'XXX' referenced before assignment错误: UnboundLocalError:在赋值之前引用了局部变量“XXX”例:def test(): i=i+1 print("global i = ",i)i=0test()报错:原因...原创 2019-07-09 09:17:54 · 6479 阅读 · 0 评论 -
python 使用matplotlib
1、matplotlib官网https://matplotlib.org/2、下载页面,选择版本https://pypi.org/project/matplotlib/#files3、将其下载的文件,放入到python安装目录下的Scripts文件中通过命令行的方式进入该目录下,执行命令pip install matplotlib-3.0.3-cp35-cp35m-wi...原创 2019-04-19 09:12:20 · 255 阅读 · 0 评论 -
python学习之集合set
python学习之集合set集合(set)是一个无序的不重复的元素序列if __name__== '__main__': """ #1_创建集合 (1)parame={value01,value02...} (2)set(value) #set中只能有一个参数 【注】创建一个空集合必须用set()而不是{},因为{}用来创建一个空字典 """ print('\n1_创建集合...原创 2019-03-22 10:18:52 · 137 阅读 · 0 评论 -
python错误_set集合
1、错误2、问题3、解决:set()最多只有一个参数原创 2019-03-22 10:12:02 · 421 阅读 · 0 评论