对于模块名/包名、函数名、变量名、类名、常量名的命名,Python有一些公认的规则,具体如下。
模块名/包名:全小写字母,简单有意义。
<code>import numpy
import matplotlib/<code>
类名:用骆驼写法,由多个单词组成名称,其每个单词的首字母大写。
<code>class MyClass()
class VehicleMovement()/<code>
函数名:全小写字母,可以使用下划线增加可阅读性
<code>def my_function(x, y)
def update_veh_pose(pose, vel, steer)/<code>
变量名:全小写字母,可以使用下划线增加可阅读性
<code>vel = 10.0
steer = 1.0/<code>
常量名:全部大写字母,可以使用下划线增加可阅读性
<code>LENGTH = 5.0
WHEEL_BASE = 2.0/<code>
閱讀更多 算法集市 的文章