自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 资源 (1)
  • 收藏
  • 关注

原创 Python错误集锦:pandas绘制多个子图时报错:AttributeError: ‘list’ object has no attribute ‘get_figure’

原文链接:http://www.juzicode.com/archives/3273错误提示:利用pandas绘制多个子图时报错:AttributeError: ‘list’ object has no attribute ‘get_figure’#juzicode.com #vx:桔子codeimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltplt.rc('font',family='Youy.

2020-12-30 19:46:09 5675

原创 Python错误集锦:pyplot.hist()绘制直方图时提示:ValueError: x must have 2 or fewer dimensions

原文链接:http://www.juzicode.com/archives/3139错误提示:pyplot.hist()绘制直方图时提示:ValueError: x must have 2 or fewer dimensions#juzicode.com,#VX:桔子codeimport numpy as npimport matplotlib.pyplot as pltplt.rc('font',family='Youyuan',size='9')plt.rc('axes',u.

2020-12-30 19:44:29 3709

原创 数据可视化~pandas绘图(熊猫会画图?)

在matploblib中,绘图操作通常可以用pyplot.plot()实现,但是如果需要在一个画布上绘制多张图片,则需要用到subplots()或subplot()方法。1、subplots()1.1、生成单个子图利用pyplot.subplots(),不带参数时,默认参数nrows=1,ncols=1,表示生成1行1列的1个子图,绘图效果同pyplot.plot():import matplotlibimport matplotlib.pyplot as pltimport nump

2020-12-30 18:39:47 1438

原创 Python错误集锦:在pandas中用to_excel()写文件提示:ModuleNotFoundError: No module named ‘xlwt’

原文链接:http://www.juzicode.com/archives/3127错误提示:在pandas中用to_excel()写文件提示:ModuleNotFoundError: No module named ‘xlwt’:import numpy as npimport pandas as pdarr = np.random.randint(-50,50,size=(3,10))ind = [x for x in range(3)]columns = list('ABC.

2020-12-28 20:06:53 4264

原创 Python错误集锦:pandas读取excel提示ImportError: Missing optional dependency ‘xlrd’.

原文链接:http://www.juzicode.com/archives/3125错误提示:用pandas read_excel()方法读取xls或xlsx文件时,提示:ImportError: Missing optional dependency ‘xlrd’. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.import numpy as npimport pandas as.

2020-12-28 19:47:28 37518 1

原创 数据可视化~matplotlib饼图、柱状图

原文链接:http://www.juzicode.com/archives/25301、饼图使用pie()方法绘制饼图:print('\n-----欢迎来到juzicode.com')print('-----公众号: 桔子code/juzicode \n') import matplotlib.pyplot as pltif __name__ == '__main__': plt.rc('font',family='Youyuan',size='9') ..

2020-12-28 08:21:38 992 2

原创 数据可视化~matplotlib显示多个子图

原文链接:http://www.juzicode.com/archives/25321、subplots()A、生成单个子图利用pyplot.subplots(),不带参数时,表示生成1行1列的1个子图,效果通pyplot.plot():import matplotlibimport matplotlib.pyplot as pltimport numpy as npif __name__ == '__main__': plt.rc('font',family='Yo.

2020-12-25 08:27:29 4887 4

原创 数据可视化~matplotlib基本画图方法

原文链接:http://www.juzicode.com/archives/2455这篇博文开始介绍任何利用matplotlib画图,在python3.8及以下版本中matplotlib不是标准库,需要先通过pip安装matplotlib:pip install matplotlib先从一段最简单的画图代码开始,看下使用matplotlib的基本步骤:import numpy as npimport matplotlib.pyplot as pltx = np.arange(.

2020-12-24 21:00:21 1643 1

原创 Python错误集锦:三引号注释提示错误:IndentationError: expected an indented block

原文链接:http://www.juzicode.com/archives/2840错误提示:定义函数时,使用三引号注释提示错误:IndentationError:expected an indented block#juzicode.com/vx:桔子codedef fuc():'''定义一个函数''' print('桔子code') print('juzicode.com') return None#调用func函数fuc()..

2020-12-21 21:04:04 2103

原创 Python错误集锦:开启线程时提示TypeError: func() argument after * must be an iterable, not int

原文链接:http://www.juzicode.com/archives/2756错误提示:开启线程时提示TypeError: func_one_para() argument after * must be an iterable, not int#juzicode.com/vx:桔子codeimport threadingdef func(para1): print(para1)if __name__ == '__main__': para1 =11...

2020-12-20 12:26:30 4548 2

原创 Python错误集锦:with方法打开文件提示:ValueError: I/O operation on closed file.

原文链接:http://www.juzicode.com/archives/2749错误提示:使用with方法打开文件后,再次read()文件时提示:ValueError: I/O operation on closed file.#juzicode.com/vx:桔子codewith open('example-r.txt','r') as fileobj: cont = fileobj.read() print(cont)fileobj.read()juzi.

2020-12-20 12:25:34 2365 1

原创 Python错误集锦:读写文件时提示UnsupportedOperation: not readable

原文链接:http://www.juzicode.com/archives/2745错误提示:读写文件时提示UnsupportedOperation: not readable#juzicode.com/vx:桔子codefileobj=open('example-r.txt','r')cont = fileobj.read()print(cont)fileobj=open('example-w.txt','w')cont = fileobj.read()print(con.

2020-12-20 12:25:17 1821 1

原创 Python错误集锦:字符串到10进制转换时提示:ValueError: invalid literal for int() with base 10: ‘1a‘

原文链接:http://www.juzicode.com/archives/2736错误提示:字符串到10进制转换时提示:ValueError: invalid literal for int() with base 10: ‘1a’#juzicode.com/vx:桔子codea = int('135',10)print('a=',a)b = int('1a',10)print('b=',b)a= 135--------------------------------.

2020-12-20 12:24:56 680 1

原创 Python错误集锦:使用%s格式化tuple类型的字符串:TypeError: not all arguments converted during string formatting

原文链接:http://www.juzicode.com/archives/2731错误提示:使用%s格式化tuple类型的字符串时提示:TypeError: not all arguments converted during string formatting#juzicode.com/vx:桔子codec = '桔子code'd = [1,2,3,4,5]e = (1,2,3,4,5)print('c:%s'%(c))print('d:%s'%(d))print('e:%s'

2020-12-20 12:24:32 423 1

原创 Python错误集锦:格式化字符串 IndexError: Replacement index 5 out of range for positional args tuple

原文链接:http://www.juzicode.com/archives/2725错误提示:格式化字符串时提示index超出范围:IndexError: Replacement index 5 out of range for positional args tuple#juzicode.com/vx:桔子codea = 3b = 5.12345c = '桔子code'd = [1,2,3,4,5]e = (1,2,3,4,5)f = {1,2,3,4,5}out = 'a:

2020-12-20 12:24:03 27341 1

原创 Python错误集锦:set计算并集时TypeError: unsupported operand type(s) for +: ‘set’ and ‘set’

原文链接:http://www.juzicode.com/archives/2720错误提示:#juzicode.com/vx:桔子codes1={1,2,3,4}#集合s1s2={3,4,5,6}#集合s2print('s1-s2:',s1-s2)print('s1+s2:',s1+s2)s1-s2: {1, 2}---------------------------------------------------------------------------TypeErro

2020-12-19 11:46:21 4250 1

原创 Python错误集锦:list dict类型的数据作为set元素TypeError: unhashable type: ‘list‘ TypeError: unhashable type: ‘dict

原文链接:http://www.juzicode.com/archives/2715错误提示:构建set类型的数据时,使用tuple类型的数据作为元素没有问题,使用list、dict类型的数据作为元素报TypeError: unhashable type: ‘list’、 TypeError: unhashable type: ‘dict’#juzicode.com/vx:桔子codet = ('juzicode.com', '桔子code', '橙子')l = ['juzicode.co

2020-12-19 11:41:34 635 1

原创 Python错误集锦:字典使用数字类型的下标访问时提示KeyError: 0

原文链接:http://www.juzicode.com/archives/2711错误提示:list使用数字类型的下标访问没有问题,字典使用数字类型的下标访问时提示KeyError: 0#juzicode.com/vx:桔子codel = ['juzicode.com', '桔子code', '橙子']print(l[0])d = {'A':'juzicode.com','B':'桔子code','C':'橙子'}print(d[0])juzicode.com--------

2020-12-19 11:32:21 2749 2

原创 Python错误集锦:调用列表的元素时提示IndexError: list assignment index out of range

原文链接:http://www.juzicode.com/archives/2692错误提示:调用列表的元素时提示:IndexError: list assignment index out of range#juzicode.com/vx:桔子codelst = ['juzicode','香蕉','苹果','西瓜']lst[1] = '火龙果'print('lst:',lst)lst[4] = '百香果'print('lst:',lst)lst: ['juzicode', '

2020-12-19 11:27:21 1958 1

原创 Python错误集锦:list类型的数据作为字典的key提示TypeError: unhashable type: ‘list’

原文链接:http://www.juzicode.com/archives/2706错误提示:用tuple类型的数据作为字典的key不报错,用list类型的数据作为字典的key时,提示TypeError: unhashable type: ‘list’#juzicode.com/vx:桔子codetuple1 = (1,2,3)tuple2 = (4,5,6)d3 = {tuple1:10,tuple2:20} #用tuple作为字典的keyprint(d3) list1 = [1,

2020-12-19 11:27:11 678 1

原创 Python错误集锦:使用list.index()提示ValueError: 20 is not in list

原文链接:http://www.juzicode.com/archives/2701错误提示:使用list的index方法查找元素时提示:ValueError: 20 is not in list#juzicode.com/vx:桔子codelst = [1,3,9,5,21]a = lst.index(3)print('3第1次出现的位置',a)a = lst.index(20)print('20第1次出现的位置',20)3第1次出现的位置 1--------------

2020-12-19 11:26:48 16571 1

原创 Python错误集锦:除法运算时提示ZeroDivisionError: division by zero

原文链接:http://www.juzicode.com/archives/2669错误提示:进行除法运算时,提示ZeroDivisionError: division by zero#juzicode.com/vx:桔子codelst = [5,4,3,2,1,0]for l in lst: b = 10/l print('l=',l,'b=',b)l= 5 b= 2.0l= 4 b= 2.5l= 3 b= 3.3333333333333335l= 2 b=

2020-12-19 11:26:37 75683 2

原创 Python错误集锦:subplot提示ValueError: Single argument to subplot must be a three-digit integer, not 3411

原文链接:http://www.juzicode.com/archives/2498错误提示:使用matplotlib画子图时提示:ValueError: Single argument to subplot must be a three-digit integer, not 3411Traceback (most recent call last): File "13-plt-subplot-子图限制.py", line 30, in <module> ax3 =

2020-12-18 19:46:45 6566 3

原创 Python错误集锦:SyntaxError: invalid character in identifier

原文链接:http://www.juzicode.com/archives/2672错误提示:使用print()函数打印字符串,提示print后面的括号是无效字符:SyntaxError: invalid character in identifier#juzicode.comimport numpy as npa = np.arange(24)print('a.size=',a.size) File "<ipython-input-7-bc4a16c715d1>",

2020-12-18 19:45:09 1119 1

原创 桔子菌用Python turtle画的桔子

原文链接:http://www.juzicode.com/archives/2575要画桔子,先对着个桔子看几分钟:看完了桔子该动手了,先画个外形:print('\n-----欢迎来到juzicode.com')print('-----公众号: 桔子code/juzicode \n') import turtleturtle.setup(width=700,height=500)turtle.speed(10)#画桔子本身turtle.penup()turtle.goto

2020-12-16 07:57:39 1173 2

原创 Python错误集锦:打开文件路径提示参数无效,OSError: [Errno 22] Invalid argument: ‘D:\juzicode\桔子code\readme.txt’

原文链接:http://www.juzicode.com/archives/2493错误提示:打开文件路径提示参数无效:OSError: [Errno 22] Invalid argument: ‘D:\juzicode\桔子code\readme.txt’D:\juzicode>python read_file.pyTraceback (most recent call last): File "read_file.py", line 4, in <module>

2020-12-12 08:23:02 1382 2

原创 Python错误集锦:matplotlib legend提示:ValueError: Unrecognized location ‘upper’. Valid locations are

原文链接:http://www.juzicode.com/archives/2486错误提示:使用matplotlib legend提示:ValueError: Unrecognized location ‘upper’. Valid locations areTraceback (most recent call last): File "09-plt-step.py", line 30, in <module> plt.legend(title='参数where:'

2020-12-09 20:08:29 2894 4

原创 Python错误集锦:TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’

原文链接:http://www.juzicode.com/archives/2411错误提示:进行加减法运算时提示:TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’:D:\juzicode>python test.pyTraceback (most recent call last): File "test.py", line 6, in <module> c=a+bTypeErr..

2020-12-08 22:37:14 38819

原创 Python数据可视化~matplot默认配置修改(可解决中文、负号等显示问题)

原文链接:http://www.juzicode.com/archives/2421在matplotlib中默认是不能正常显示中文:import numpy as npimport matplotlib.pyplot as pltimport matplotlib as mplif __name__ == '__main__': x = np.arange(-3,5) y = x*x*x plt.title("桔子code") plt.xlabel.

2020-12-08 22:36:47 1691 1

原创 好冷的Python~ 那些同名的家伙们

原文链接:http://www.juzicode.com/archives/1466前两天桔子菌在调试代码的时候发现自己写的一个方法怎么也执行不到,这个自定义的类大概是下面这样子的:class ClassA(object): def __init__(self,filename): self.name = '公众号: 桔子code' self.filename = filename self.data = None

2020-12-07 12:51:11 156

原创 Python错误集锦:NameError: name ‘a’ is not defined

原文链接:http://www.juzicode.com/archives/2364错误提示:使用变量时提示NameError: name ‘a’ is not definedD:\juzicode>python test-not-define.py微信公众号: 桔子code / juzicode.comb= 5Traceback (most recent call last): File "test-not-define.py", line 5, in <module&

2020-12-06 20:29:22 18749 1

原创 windows命令行提权方法

原文链接:http://www.juzicode.com/archives/2344某些命令在windows cmd命令行下提示“请求的操作需要提升”:发生这种错误一般是因为启动cmd是以普通用户打开的,需要用管理员身份启动命令行,可以新建”启动命令行.bat”文件,文本方式打开输入“cmd”保存,右键“以管理员身份运行”:这样启动的cmd命令行是以管理员身份启动的,就能获得管理员权限,这时再输入命令就不会出现错误提示:...

2020-12-01 21:35:22 3077

原创 奇文共欣赏~UTF-8设计与源码实现

在《编码: 一个隐藏了30多年的bug,Windows含蓄说过某通不行?》一文中我们简单讨论了Unicode和UTF-8的关系,UTF-8本身并不是一种字符集,而是实现Unicode字符集的一种编码方式。RFC3629规定的Unicode字符集和UTF-8编码的对应关系是下图这样的:1、设计原则在Unicode官网上V1.1.0的附录部分 (https://www.unicode.org/versions/Unicode1.1.0/appF.pdf) 介绍了UTF-8编解码的设计原则和C语言的实

2020-12-01 12:37:21 306

python-openpyxl读写Excel

openpyxl读写excel文件实例

2024-06-17

tesseract训练mnist-by juzicode.com-vx桔子code

包含mnist数据集,训练脚本,测试脚本、eng字体

2021-11-25

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除