将元组乘以标量 [英] Multiplying a tuple by a scalar
本文介绍了将元组乘以标量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
print(img.size)
print(10 * img.size)
这将打印:
(70, 70)
(70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70)
我要打印:
(700, 700)
有什么方法可以做到而不必写:
Is there any way to do this without having to write:
print(10 * img.size[0], 10 * img.size[1])
PS:img.size
是PIL图像.邓诺在这种情况下是否有关系.
PS: img.size
is a PIL image. Dunno if that matters anything in this case.
推荐答案
可能是更好的方法,但这应该可行
Might be a nicer way, but this should work
tuple([10*x for x in img.size])
这篇关于将元组乘以标量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文