我正在使用记录和列表尝试这个简单的收据代码,在不同的客户之间我希望有一个新行,但因为它在列表中\n
不起作用
我尝试过在代码中的不同部分添加\n
,也尝试过添加print("\n")
,但这也不起作用
from collections import *
customer_details = namedtuple("Customer","ID First_Name Surname Age Gender Product Price")
cus1 = customer_details(16785, "John","Apleased",36,"Male","coffee",70)
customers = [cus1]
cus2 = customer_details(10, "Steve","Jobs",67,"male","tea",40)
customers.append(cus2)
print(customers)
当你查看列表时,客户之间应该有一个间隙
可以使用join方法在新行中打印每个元素
可以使用
for
循环或者可以使用
'\n'.join()
,但是首先需要将customers
从namedtuple
列表转换为字符串列表相关问题 更多 >
编程相关推荐