The Problems For Using PyCharm

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

The Problems For Using PyCharm_第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
jThe Problems For Using PyCharm_第2张图片
在Stackoverflow里面看到,在定义下面添加pass
The Problems For Using PyCharm_第3张图片

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.

The Problems For Using PyCharm_第4张图片
此时我们对属性的操作是动态绑定的,是在程序运行的过程中对class添加的功能,我们只要在类中对属性进行限制,即允许动态绑定的属性进行说明

class Student(object):
    __slots__ = ('name', 'age', 'set_age')
    pass

The Problems For Using PyCharm_第5张图片

4、使用ImageFont设置字体时出错,即:

font = ImageFont.truetype('Arial.ttf', 36)

The Problems For Using PyCharm_第6张图片
给字体添加路径C:\Windows\Fonts[要添加的字体],例如:

font = ImageFont.truetype('C:\\Windows\Fonts\Arial.ttf', 36)

The Problems For Using PyCharm_第7张图片

你可能感兴趣的:(Python)