python - 在 for 循环中打印一个列表,其中的标题连接到每个值
问题描述
for 循环给出了这个错误,ValueError: not enough values to unpack (expected 3, got 1)
for (item,price,quan) in shoplist:
print('Item:',item, 'Price:$',price, 'Quantity:',quan)
希望它看起来像
商品:牛奶 价格:1.00 美元 数量:4 商品:苹果 价格:1.00 美元 数量:5
解决方案
推荐阅读
- java - Quarkus 使用 Mandrel 原生构建
- java - 通过使用带有.get(位置)的回收器视图适配器,我无法从回收器视图java中的edittext获取文本
- sybase - 在 aqua 数据工作室中调试过程时是否可以运行查询?
- angular - “订阅”类型不可分配
- html - 更改单独的元素样式以关注其他元素
- react-native - 将内联日志显示为多行
- r - 使用存储在 R 中的向量中的名称存储数据帧
- r - 为什么回归曲线不是(显示的)线性(ly)?
- php - 如何修复 Magento 2 编译问题?
- python - 如何对齐和裁剪位于子目录中的图像以进行人脸识别?