擅长:python、mysql、java
<p>假设signal level是任何行上唯一的负数,那么可以使用正则表达式和<a href="https://docs.python.org/2/library/re.html#re.findall" rel="nofollow">findall</a>函数来搜索文件中的所有负数,并将它们作为字符串列表返回(基于MC93的答案)。在</p>
<pre><code>import re
f_in = open("input.txt", "r")
signal_levels = re.findall("-\d+", f_in.read())
</code></pre>
<p>或者,您可以得到一个包含列表理解的int列表。在</p>
^{pr2}$