Django使用
makemigrations
做数据迁移的时候报如下错误
File "/Users/jkc/.virtualenvs/django_env/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query
query = query.encode(errors='replace')
AttributeError: 'bytes' object has no attribute 'encode'
进入到operations.py
文件中,找到第146行,原来的代码是这样的

改为下图所示即可

这里为了方便,复制下面代码即可
query = query.encode(errors='replace') if isinstance(query, str) else query.decode(errors='replace')
attributeError: 'NoneType' object has no attribute 'shape' 报错
attributeError: 'NoneType' object has no attribute 'shape' 报错
attributeError: 'NoneType' object has no attribute 'shape' 报错 可能是因为没有设置路径,所以返回的类型是None。 改正的方法是,读取图片时把路径也写上
AttributeError: ‘list‘ object has no attribute ‘reshape‘ ‘list‘ object has no attribute ‘reshape‘
def image2vector(image): """ Argument: image -- a numpy array of shape (length, height, depth) Returns: v -- a vector of shape (length*height*depth, 1) """ 将三维变为一维输出 v = np.array(image).reshape(np.array(image).sh.