擅长:python、mysql、java
<p>您需要将您的人员添加到列表中,以便在其中进行搜索。仅仅因为您有一个名为<code>x1</code>的变量,并不意味着您可以使用<code>(username).fullname()</code>来引用该变量。Python不是这样工作的</p>
<pre><code>names = [
person('x1', 'y1', 50000, 2002, 2, 22)
person('x2', 'y2', 60000, 2004, 4, 24)
]
flag = 0
for user in names:
if user.first == username:
print( user.first, user.fullname())
flag=1
break
if flag == 0:
print("element not found")
</code></pre>