f.readlines(): 如何在没有额外数字的情况下打印

f.readlines(): how to print without extra figures

我正在尝试从 f.readlines 打印。从代码中可以看出,当我打印 a 时,它会在一个新行中打印每个元素,而不会添加任何额外的内容 (\,n,")。但是,当我尝试拆分字符串并仅调用特定元素时,它会添加额外的内容符号。我该如何解决这个问题?

cargo.txt
wardrobe 550.30
mattress 300.10
fauteuil 600.00
drawer 1230.55
hammock 75.00

code:

import sys
fn = sys.argv [1]
wl= sys.argv [2]
with open ("cargo.txt","r") as f:
    a = (f.readlines())
    print(*a)
    b = a.split()
    print(b[1])

以下是提取所有浮点数的方法:

with open ("cargo.txt","r") as f:
    a = [l.split()[1] for l in f.readlines()]
    print(a)

输出:

['550.30', '300.10', '600.00', '1230.55', '75.00']