擅长:python、mysql、java
<p>简单的解决方案</p>
<pre><code>username = input()
with open('clientRecords.txt', 'r') as clientsfile:
for line in clientsfile:
if line.startswith("%s, " % username):
print("Client %s found: %s" % (username, line.split(",")[1]))
break
</code></pre>
<p>For循环遍历文件行,当我们发现行以所需的客户机名称开始时,我们打印地址并中断循环。你知道吗</p>