本文整理匯總了Python中collections.Counter.isalpha方法的典型用法代碼示例。如果您正苦於以下問題:Python Counter.isalpha方法的具體用法?Python Counter.isalpha怎麽用?Python Counter.isalpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類collections.Counter
的用法示例。
在下文中一共展示了Counter.isalpha方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: shortestCompletingWord
# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import isalpha [as 別名]
def shortestCompletingWord(licensePlate, words):
"""
:type licensePlate: str
:type words: List[str]
:rtype: str
"""
d = {}
licensePlate = licensePlate.lower()
for c in licensePlate:
if c.isalpha():
d[c] = d.get(c, 0) + 1
res1 = ''
res2 = ''
length1 = length2 = 20
for word in words:
n = len(word)
all_in, flag = f(n, word, d)
if all_in and n < length1:
res1 = word
length1 = n
if flag and n < length2:
res2 = word
length2 = n
if res1:
return res1
return res2