python - 如何遍历多个列表以返回具有良好语法的元组
问题描述
我想以最简洁的方式编写这段代码:
def test_roomVolume(self):
widths = [4, 1, 4, 4, 1, 4, 1, 1]
lengths = [4, 4, 1, 4, 1, 1, 4, 1]
heights = [4, 4, 4, 1, 4, 1, 1, 1]
expected = [64, 0, 0, 0, 0, 0, 0, 0]
for i in range(len(widths)):
dimensions = (widths[i], lengths[i], heights[i])
有没有更好的方法来创建维度元组?喜欢
dimensions = (widths, lengths, heights)[i]
类似的东西?
解决方案
推荐阅读
- android - beeware将toga imageview添加到android
- c++ - 队列和文本文件
- amazon-web-services - AWS Data Exchange 限制如何避免?
- angular - NgRx 存储选择器单元测试
- java - 如何使用以当前日期为输入的java获取下一个日期
- c# - Xna 可破坏的墙壁
- microsoft-graph-api - 尝试在 MS Graph 中创建会议时出现内部服务器错误
- linux - ln:创建符号链接失败:文件存在
- angularjs - 如何设置织物组的边界框旋转和尺寸与其对象相同
- c - 在C中找到数组中的最小数字的问题