相关疑难解决方法(0)

Python中变量和函数名称的命名约定是什么?

来自C#背景的变量和方法名称的命名约定通常是CamelCase或Pascal Case:

// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()
Run Code Online (Sandbox Code Playgroud)

在Python中,我已经看到了上面的内容,但我也看到了使用下划线:

# python example
this_is_my_variable = 'a'
def this_is_my_function():
Run Code Online (Sandbox Code Playgroud)

Python有更优选的,明确的编码风格吗?

python variables function naming-conventions

719
推荐指数
11
解决办法
42万
查看次数

标签 统计

function ×1

naming-conventions ×1

python ×1

variables ×1