我试图打印一个熊猫数据帧格式的二维列表。你知道吗
将数据打印为数据帧的结果
我的代码
cols = ["prod_id", "description", "cost"]
data = [["p01", "Domaxx Geniune Leather RFID Blocking Trifold Wallets-Made Genuine Soft Leather Large Classic Pocket Wallet,Holding 9 Cards Photo ID Coin Pocket and 2 Note compartments-Black Surface/Orange Inner", "10.00"],
["p02","Neck Wallet, Passport Holder with RFID Blocking Anti-Theft Travel Pouch Security Wallet for Credit Cards and Passport - Silver","15.00"]]
temp_str = ''
for item in cols :
temp_str += "\t " + item
print(temp_str)
i = 0
for row in data :
print(str(i) + "\t" + row[0] + "\t" + row[1] + "\t" + row[2])
i += 1
=============
我不确定我是否理解你的意见,但如果你想要:
发件人:
就这么做吧:
编辑
我将向您展示一个具有较短列字段的示例:
您可以使用格式的值来达到最适合您的结果
相关问题 更多 >
编程相关推荐