擅长:python、mysql、java
<p>文件中的行中有超过1个空格。当你想分手的时候。得到1、2、3、4和更多的值,但在拆分后只有2个值</p>
<pre><code>dictionary = {}
with open(r"C:\Users\acer\Desktop\WIEN2k.txt") as file:
for line in file:
values = line.strip().split(" ")
if values:
dictionary[value[0]] = values[1:]
print(dictionary)
</code></pre>
<p><a href="https://python-reference.readthedocs.io/en/latest/docs/str/split.html" rel="nofollow noreferrer">https://python-reference.readthedocs.io/en/latest/docs/str/split.html</a>更多关于<code>string.split()</code></p>