标识符是否符合要求判定
import keyword import string alp = string.letters +'_' nums = string.digits print "welcome to identifier check v1.0." print "you have to enter two char to identifier." keywords= keyword.kwlist myinput =raw_input(">") if myinput[0] not in alp: print "invalid:first symbol must be alphabetic" else : if len(myinput) == 1 and myinput not in keywords: print "right,ok,done" myinput1 = myinput[1:] for otherchar in myinput[1: ]: if otherchar not in alp + nums or myinput in keywords: print "invalid,need symbols ." break