变量名称
¥Variable Names
有效的变量名必须仅包含字母(大写或小写)、数字和下划线 (_
),并且不能以数字开头。
¥A valid variable name must contain only letters (uppercase or lowercase), digits and underscores
(_
) and it can't begin with a digit.
更具体地说,有效的变量名必须符合以下正则表达式:
¥More specifically a valid variable name must match the following regular expression:
^[a-zA-Z_]+[a-zA-Z0-9_]*$
建议的约定是必要时使用大写字母、下划线和数字,但任何符合上述定义的变量名都可以。
¥The recommended convention is to use capital letters with underscores and digits when necessary, but any variable name respecting the above definition will work just fine.
例如,以下是一些有效的变量名:MY_VAR
、MY_VAR_1
、my_var
、my_var_1
、myVar
、My_Var123
,但以下无效:1_VAR
, 'my-var'
, "my var"
, VAR_#1
.
¥For example, the following are some valid variable names: MY_VAR
, MY_VAR_1
, my_var
, my_var_1
,
myVar
, My_Var123
, while these are instead not valid: 1_VAR
, 'my-var'
, "my var"
, VAR_#1
.