def searchContact():
obj1 = open("address.txt","r")
number = raw_input("Enter phone number to search data : ")
for line in obj1.readlines():
if number in line:
print line
obj1.close()
def searchContact():
number=raw_input("Enter phone number to search data : ")
obj1=open("file.txt","r")
for line in obj1.readlines():
if number in line:
print(line)
obj1.close()
def searchContact():
number=raw_input("Enter phone number to search data : ")
obj1=open("file.txt","r")
re=obj1.read()
print re
x= re.split("\n")
matching = [s for s in x if number in s]
print matching
obj1.close()
searchContact()
这个简单的代码就可以完成这项工作
希望这能有所帮助。如果是,接受并投赞成票
相关问题 更多 >
编程相关推荐