import string
def is_valid_identifier(param):
alphas = string.letters + '_'
nums = string.digits
if len(param) > 1:
if param[0] not in alphas:
print 'invalid:first symbol must be alphabetic'
else:
for otherChar in param[1:]:
if otherChar not in alphas + nums:
print 'invalid:reminding symbols must be alphanumeric'
break
else:
print 'okay, %s is an valid identifier'%param
is_valid_identifier('class') 以上就是关于python判断参数是否是合法标识符介绍的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于关于python判断参数是否是合法标识符介绍的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did85432