我在一个示例程序中发现了以下代码:
>>> monitor = {'top': 5, 'left': 0, 'width': 1000, 'height': 200}
>>> output = 'sct-{top}x{left}_{width}x{height}.png'.format(**monitor)
>>> print(output)
sct-5x0_1000x200.png
看起来.format(**monitor)
是一种**kwargs
类型的东西,但是我以前没有用过这些东西。你知道吗
我“解除”了这个代码,知道它是如何工作的,但我的理解能让我陷入困境吗?你知道吗
我正要发布这个问题,但先运行了这个:
>>> '{} {} buckle my {top}'.format(1, 2, **monitor)
'1 2 buckle my 5'
所以我想我现在可以说我积极地与kwargs
合作。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐