擅长:python、mysql、java
<p>如果要只读以“temperatuur”开头的行:</p>
<pre><code>with open('weerstation.txt') as f:
L = [line for line in f.readlines() if line.startswith('temperatuur')]
</code></pre>
<p>如果要将“temperatuur 20.8 10.4\n”这样的行拆分为三个值,请使用split函数(但不要忘记value1和value2将是字符串,如果要创建图形,则必须将它们转换为数字):</p>
<pre><code>label, value1, value2 = line.split()
</code></pre>