代码如下:
#encoding=utf-8
print '中国'
#检查字符串中是否包含某字符集合中的字符
#方案一 适用于字符串集合
print '---1'
def ContainAny(seq,aset):
for c in seq:
if c in aset:
return True
return False
print ContainAny('abc中国','a')
print ContainAny(u'abc中国','a')
print ContainAny(u'abc中国','中')
#print ContainAny('中',u'abc中国') 不能编译
#方案二 迭代器方法
import itertools
def ContainAnyIter(seq,aset):
......
阅读全文