回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一个文本文件说</p>
<pre><code>Mash,25.50,108.00
Enhanced,37.50,162.00
Pellets,30.00,135.00
Protein Plus,39.00,174.00
Calcium Plus,39.00,174.00
</code></pre>
<p>我把它写进了一份打印报表</p>
<pre><code>def readfile():
textlist = [line.split(',') for line in open("chookfood.txt", 'r')]
print(','.join([str(lst) for lst in textlist]))
readfile()
</code></pre>
<p>它输出这个嵌套列表:</p>
<pre><code>['Mash', '25.50', '108.00\n'],['Enhanced', '37.50', '162.00\n'],['Pellets', '30.00', '135.00\n'],['Protein Plus', '39.00', '174.00\n'],['Calcium Plus', '39.00', '174.00']
</code></pre>
<p>如何将print语句转换为print mash[1]。我无法将这些值存储在python idle中,因此我需要一些方法来询问如何从mash打印25.50?你知道吗</p>