python标识符必须以什么开头,新语法规则
python标识符必须以什么开头
在python3之后,因为设计了以汉字命名python标识符的规则,因此,在此之前,Python的标识符通常必须以字母或下划线开头的语法规则就发生了改变,变成了必须以字母或下划线或汉字开头,本站为此提供了不少的实例,下面我们再来写几行代码来验证一下:
实例
>>> 域ming = 'x1y1z1.com'
>>> 域ming
'x1y1z1.com'
>>> a=1
>>> a
1
>>> _a=2
>>> _a
2
>>> _网站 = '大器编程'
>>> _网站
'大器编程'
>>> *c
File "<stdin>", line 1
SyntaxError: can't use starred expression here
>>> *c = 1
File "<stdin>", line 1
*c = 1
^
IndentationError: unexpected indent
>>> *c=3
File "<stdin>", line 1
SyntaxError: starred assignment target must be in a list or tuple
python标识符的命名规范,具体的可以参考本站的python语法教程:python的标识符命名规则,保留字表