标签:invalid symbols python import
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‘)
备注:除了关键字和一个长度的
标签:invalid symbols python import
原文地址:http://11565901.blog.51cto.com/11555901/1908462