来自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有更优选的,明确的编码风格吗?
我有字符串例如:"238 NEO Sports".我想只在第一个空格分割这个字符串.输出应该是["238","NEO Sports"].
我能想到的一种方法是使用split()并最终合并返回的最后两个字符串.有没有更好的办法?