-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path9.4.py
More file actions
32 lines (27 loc) · 851 Bytes
/
9.4.py
File metadata and controls
32 lines (27 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#coding:utf-8
"""
写一个名叫uses_only的函数,接收一个单词和一个字母字符串,如果单词仅包含该字符串中
的字母,就返回真。你能仅仅用 acefhlo 这几个字母造句子么?或者试试『Hoe alfalfa』?
"""
def uses_only(word,letter):
for ch in word:
if ch not in letter:
return False
return True
#print uses_only('ace','acefhlo')
def search():
fin = open('C:\Users\LzyRapx\PycharmProjects\untitled\words.txt')
while True:
line = fin.readline()
# print line
# if line == "aah ":
# print line
if uses_only(line,'aahacefhlo'):
print line
if not line:
break
print "Done"
#search()
if __name__ == '__main__':
print uses_only('ace', 'acefhlo')
search()