![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python错误
向东的笔记本
投其所好,终有所成!
展开
-
【已解决】OpenCV Error: Sizes of input arguments do not match
问题描述今天在使用opencv中的bitwise_and函数进行图像“与”操作的时候遇到了如下的问题:下面是我的源代码:saliency = psal.get_saliency_rbd(image).astype('uint8')ori_mask = cv2.imread(mask, 0)result = cv2.bitwise_and(ori_mask, saliency)下面是暴...原创 2020-04-21 11:44:03 · 17616 阅读 · 2 评论 -
【已解决】AttributeError: module 'labelme.utils' has no attribute 'draw_label'
问题重现由于重新装了Anaconda和新的虚拟环境,所以把labelme升级到了最新版,4.2.9。为了实现批量转换,在网上找了代码对json_to_dataset进行了替换,但是,转换时却遇到了如下错误:Traceback (most recent call last): File "/Users/lalala/opt/anaconda3/envs/cv/lib/python3.6/si...原创 2020-03-07 22:14:20 · 2306 阅读 · 0 评论 -
python中的yield关键字是个什么鬼?它有什么用处?
yield是一个常用于python函数定义中的关键字,它的作用是返回一个可以用来迭代(for循环)的生成器,它的应用场景通常为一个需要返回一系列值的,含有循环的函数中。如果想要彻底搞懂yield关键词的用法,你务必先要搞懂如下词的意思:迭代,可迭代,迭代器,生成器。接下来我将逐一介绍这些词的含义,以及相应的用法。迭代(iteration)和可迭代(iterable)迭代是一种操作。很多...原创 2018-07-16 08:25:06 · 9554 阅读 · 3 评论 -
Python错误:AttributeError: 'generator' object has no attribute 'next'解决办法
今天在学习生成器对象(generation object)运行以下代码时,遇到了一个错误:#定义生成器函数def liebiao(): for x in range(10): yield x#函数调用g = liebiao()#打印元素print(g.next())D:\>python test.pyTraceback (most recent call la...原创 2018-07-16 10:04:39 · 30130 阅读 · 3 评论 -
Python错误:AttributeError: 'Worksheet' object has no attribute 'get_highest_row' 解决办法
今天开始学习《python编程快速上手》中的第12章:处理Excel电子表格。但是遇到了点小问题。当我按照书中的方法获取最大行和最大列的时候,出现了下面的错误提醒:import openpyxlwb = openpyxl.load_workbook('example.xlsx')sheet = wb.get_sheet_by_name('Sheet1')print(sheet.ge...原创 2018-06-04 18:02:42 · 40325 阅读 · 12 评论 -
Python错误:ImportError: cannot import name get_column_letter 解决办法
昨天刚遇到了因为python版本更新而遇到的错误,今天一大早又遇到了一次......同样也是按照书《Python编程快速上手》P221页上的代码做练习,但是却遇到了如下的错误:import openpyxlfrom openpyxl.cell import get_column_letter,column_index_from_letterwb = openpyxl.load_wor...原创 2018-06-05 09:07:12 · 11078 阅读 · 8 评论 -
Windows10安装MongoDB出错:Your System has not been motified.To Install this program at a later time
MongoDB是一种非关系型数据库,这种数据库对于爬虫的学习来说是一种利器,因为我们爬到的数据往往都是结构化的字典型数据。在数据存储的过程当中我们无需关心表的结构,直接将数据进行字典形式的插入即可。在我的Windows10 64位的电脑中安装MongoDB时遇到了点小小的故障,在安装进行到最后一步的时候,安装程序竟然提醒我:Google之后,我在StackOverFlow中找到了答案,...原创 2018-06-14 16:41:53 · 4717 阅读 · 0 评论 -
python错误: TypeError: the JSON object must be str, bytes or bytearray, not 'dict'解决办法
当我尝试运行以下代码,来练习使用json.loads()和json.dumps()函数时,系统给我报出了这个错误。import jsontext = {"a":1,"b":2,"c":3}j = json.loads(text)print(j)Traceback (most recent call last): File "test.py", line 5, in <m...原创 2018-07-14 21:46:16 · 63932 阅读 · 7 评论 -
Python错误:AttributeError: module 'json' has no attribute 'loads'解决办法
今天在学习python中json模块的时候遇到了点让我怀疑人生的问题。像往常一样,我在电脑d盘根目录创建了一个:json.py的python文件,打算在这里练习一下json中的两个函数:loads()和dumps()。但是当我运行了如下代码的时候,它竟然提示我:AttributeError: module 'json' has no attribute 'loads',翻译成汉语的意思是:属性...原创 2018-07-13 23:04:26 · 46899 阅读 · 17 评论 -
Python错误:IndentationError:unindent does not match any outer indentation level 解决办法
1.什么错误?这个英文错误提醒翻译过来就是:缩进错误:缩进不一致。2.为何出现代码中同时使用了Tab缩进和空格缩进3.如何解决把代码中的缩进全部换成Tab,或者空格4.sublime Text如何设置Tab的大小?依次进入菜单 Preferences(首选项)—>Settings(设置)—>Ctrl+F—>搜索tab_size,将值设置为你想设置...原创 2018-07-10 20:26:42 · 2805 阅读 · 0 评论 -
python错误:docx.opc.exceptions.PackageNotFoundError: Package not found at 'new.docx'解决办法
当我尝试用如下代码打开一个word文档时,出现了如下错误:from docx import Documentdoc = Document('new.docx')Traceback (most recent call last): File "test.py", line 3, in <module> doc = Document('new.docx') F...原创 2018-07-14 22:13:02 · 24410 阅读 · 15 评论 -
Python错误:TypeError: 'int' object is not callable解决办法
今天在练习Python类相关的知识时遇到了一个TypeError,也就是类型错误。该错误的意思是Int型的对象是不可调用的(not callable)。class User(): def __init__(self,name,age,number): self.name = name self.age = age self.custom = number def cust...原创 2018-07-24 22:06:46 · 229395 阅读 · 20 评论 -
Python错误:UnboundLocalError: local variable 'total' referenced before assignment解决办法
1.错误概述今天练习类似于如下代码的时候遇到了一个UnboundLocalError错误,该错误的内容翻译过来就是:局部变量total没有定义就使用了。total = 10def change(): total = total + 1 print(total)change()D:\>python test.pyTraceback (most recent call ...原创 2018-07-25 10:21:37 · 31963 阅读 · 2 评论 -
Python错误:UnicodeDecodeError
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 216: illegal multibyte sequencedecode:解码,codec:编解码器,multibyte:多字节,illegal:非法。这是我在用Open()函数打开一个网页文档时出现的错误。此错误大概的意思就是,用gbk编码方式无法识别网页内容。...原创 2018-05-28 10:23:52 · 1150 阅读 · 0 评论 -
Python错误:IndentationError: unexpected indent
indent是缩进,空格的意思。如遇见此错误,那就是编码中有不规范的缩进问题,根据错误提醒找到对应地方更正即可: File "test.py", line 5 res.raise_for_status() ^IndentationError: unexpected indent...原创 2018-05-28 10:21:59 · 2015 阅读 · 0 评论