我有一个作为字符串的源词,我有一个字符串,人们在其中输入了一个词列表,但我如何检查输入的字符串是否只包含源词中的字符,但顺序不限
def check(input_string):
import re
#http://docs.python.org/library/re.html
#re.search returns None if no position in the string matches the pattern
#pattern to search for any character other then . a-z 0-9
pattern =word
if re.search(pattern,test_str):
#Character other then . a-z 0-9 was found
print('Invalid : %r' % (input_string,))
else:
#No character other then . a-z 0-9 was found
print('Valid : %r' % (input_string,))```