AttributeError: ‘str‘ object has no attribute ‘append‘可以使用insert代替append
a=str(age,sex,job)
a[2].insert(1,'age')
[Python]"no encoding declared
可添加编码
#coding=utf-8
或者以下声明
# -*- coding:utf-8 -*-
TypeError: not all arguments converted during string formatting
#原因是参数数量不匹配print( """Personal info:
name: %s
age : %d
sex : %s
job : %s
""" % (name,age,age,sex,job))#解决办法print( """Personal info: name: %s age : %d sex : %s job : %s """ % (name,age,age,sex,job))
Traceback (most recent call last):_src.empty() in function ‘cv::boxFilter’
将图片的中文改成英文后、收工
img = cv.imread('C://Desktop/QQ图片.jpg')
img = cv.imread('C://Desktop/QQqqqq.jpg')
UserWarning: Glyph 21407 (\N{CJK UNIFIED IDEOGRAPH-539F}) missing from current font
出错原因是python无法识别文字字体、并读取
因此要添加一下代码设置中文 # 显示中文字体
from pylab import pch
pch.rcParams["font.sans-serif"] = ["SimHei"]
UserWarning: Glyph 8722 (\N{MINUS SIGN}) missing from current font. func(*args)
出错的解析:非正常显示符号
可以添加以下代码即可
plt.rcParams['axes.unicode_minus']=False #显示符号
ERROR: No matching distribution found for cv2
显示的是没有匹配的安装包
其实cv2并非安装这个包
而是以下的包
pip install opencv-python
升级pip包显示错误
-m pip install --upgrade pip
【应改为】
python.exe -m pip install --upgrade pip
TypeError: ‘tuple’ object is not callable
源代码:rows,cols,chn=img.shape()
解释为此对象不可用
另一显示为
AttributeError: ‘tuple’ object has no attribute ‘shape’
其实我们调用了他的shape函数
而实际上我们不需要调用其函数来实现此功能
因此代码修改为:’
# 4、图像显示方式2
rows,cols,chn=img.shape
for i in range(600):
x = np.random.randint(0, rows)
y = np.random.randint(0, cols)
img[x, y, :] = 255