相关疑难解决方法(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万
查看次数

只在python中用第一个空格拆分一个字符串

我有字符串例如:"238 NEO Sports".我想只在第一个空格分割这个字符串.输出应该是["238","NEO Sports"].

我能想到的一种方法是使用split()并最终合并返回的最后两个字符串.有没有更好的办法?

python string split

30
推荐指数
3
解决办法
4万
查看次数

标签 统计

python ×2

function ×1

naming-conventions ×1

split ×1

string ×1

variables ×1