1、PEP 8: expected 2 blank lines after class or function definition, found 1

这个是格式规范的警告,可以直接运行,但是会影响美观吧,只要在定义函数后空两个空行,就可以消除警告了;
2、This dictionary creation could be rewritten as a dictionary literal less…
Inspection info: This inspection detects situations when dictionary creation could be rewritten with dictionary literal
j
在Stackoverflow里面看到,在定义下面添加pass

3、Inspection info: This inspection detects names that should resolve but don’t. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

此时我们对属性的操作是动态绑定的,是在程序运行的过程中对class添加的功能,我们只要在类中对属性进行限制,即允许动态绑定的属性进行说明
class Student(object):
__slots__ = ('name', 'age', 'set_age')
pass

4、使用ImageFont设置字体时出错,即:
font = ImageFont.truetype('Arial.ttf', 36)

给字体添加路径C:\Windows\Fonts[要添加的字体],例如:
font = ImageFont.truetype('C:\\Windows\Fonts\Arial.ttf', 36)

本文详细解析了Python编程中常见的警告信息,包括PEP8格式规范、字典创建优化、动态属性绑定及ImageFont字体设置错误,并提供了具体解决方案。
1089

被折叠的 条评论
为什么被折叠?



