#打印良好的价格表
goods={'apples':10,
'mac':500,
'book':98,
'pear':75,
'iphone X':300
}
l=[]
name_list=list(goods.keys())
price_list=list(goods.values())
print(name_list)
print(price_list)
width = int(input('请输入宽度:').strip())
price_width = 10
item_width = width-price_width
header_fmt = '{{:{}}}{{:>{}}}'.format(item_width,price_width)
fmt ='{{:{}}}{{:>{}.2f}}'.format(item_width,price_width)
print('='*width)
print(header_fmt.format('Item','Price'))
print('-'*width)
for i in range(len(name_list)):
print(fmt.format(name_list[i],price_list[i]))
print('-'*width)
python 打印良好格式的价格表
猜你喜欢
转载自blog.csdn.net/qq_42721964/article/details/81175581
今日推荐
周排行