接口开发常见报错

AttributeError: 'NoneType' object has no attribute 'strip'

本地gitlab项目没有放置data文件夹,文件夹里面没有对应的模型,模型的名字或者路径错误

Useless suppression of %s' 或者Useless suppression of 'import-error' (useless-suppression)

代表该段代码没生效

TypeError: not all arguments converted during string formatting

logging.error(a, errs)。这样写是错误的,正确是只有一个值logging.error(errs)

Formatting a regular string which could be a f-string (consider-using-f-string)

字符串的格式化尽量用f,如:print(f"result is {result}")

Variable name "xxxx" doesn't conform to '([a-z0-9_]+)$' pattern (invalid-name)

变量的名字需要小写

MySQLdb._exceptions.ProgrammingError: (1146, "Table 'xxx' doesn't exist")

代表该数据表已经删除,或者表的结构变化

TypeError: Attempted to convert a callback into a command twice.

这样写是错误的,会陷入死循环
def train():
 train()

Loading faiss with AVX2 support.

不是报错,而是因为没有需要执行的命令

TypeError: None is not a callable object

保证 a,b,c = k,k必须是一个非空的值

(wildcard-import)

import时使用了* ,建议只import 明确的库


 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

解决方法不能直接判断numpy是否为空,可以换成判断类型

TypeError: cannot unpack non-iterable NoneType object

加载模型的时候要排除模型为空的情况。

NotImplementedError

子类没有实现父类要求一定要实现的接口,

要注意子类的某个函数的缩进是否正确。

Empty class docstring (empty-docstring)

不能有空的备注

你可能感兴趣的:(开发问题,开发语言,python)