当我在命令行上输入 -->stringsearch.py joe
Expected Result: joe foe
Actual Result: joe foe
No String
代码:
#!usr/bin/python
import sys
SearchString = sys.argv[1]
def __init__(self, fname, lname):
self.fname = fname
self.lname = lname
def display(self):
if SearchString in per.fname:
print per.fname, per.lname
if SearchString in per.lname:
print per.fname, per.lname
else:
print "No String"
obj=[People("joe","foe"),People("lui","sui")]
for per in obj:
per.display()
我应该在哪里写 else 部分以获得预期的输出