0
爲什麼此代碼返回TypeError:'str'對象不可調用TypeError:'str'對象不可調用?TypeError,'str'不可調用 - Python
import string
def containsAny(stri, set):
"""Check whether 'str' contains ANY of the chars in 'set'"""
return 1 in [c in stri for c in set]
a = containsAny("acde",list(string.ascii_uppercase()))
print "{}".format(a)
您應該將'set'重新命名爲不同的內容(例如'char_set' /'iterable' /'sequence' /'seq'),以避免影響內建set。 – CristiFati