這篇文章詳解關於python判斷參數是否為合法識別碼介紹
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判斷參數是否為合法識別碼介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!