擅长:python、mysql、java
<p>要删除前面带有<code>;</code>的<code>119</code>,只需使用分号<code>split</code>:</p>
<pre><code>line.split(';')
</code></pre>
<blockquote>
<p><a href="https://docs.python.org/2/library/stdtypes.html#str.split" rel="nofollow">Return a list of the words in the string, using sep as the delimiter string.</a></p>
</blockquote>
<p>在代码中:</p>
<pre><code>import sys
my_list = []
file = sys.stdin
for line in file:
# d = {}
line = line.strip('"')
line = line.split()[0]
name = line.split(';')[0]
macAddress = line[2]
ipAddress = line[4]
#roomNum = [?]
d={'ip': ipAddress, 'mac': macAddress, 'name': name, 'room': None}
my_list.append(d)
#print line
print d
</code></pre>