Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
说我有一个功能:
def test(ab): print ab.a print ab.b
如何在不定义类的情况下轻松地将参数传递给该函数?我正在寻找类似的东西:
test({4,5})
或者
test(ab.a = 5, ab.b = 6)
这是可能吗?更改功能“测试”不是一种选择。
使用collections.namedtuple:
collections.namedtuple
import collections ab = collections.namedtuple("AB", "a b")(a=4, b=5) test(ab)
我在输出中有这个警告,但它没有作为“问题”出现(我目前没有问题)。但是在我的输出中我得到:
Warning: Attempt to present <DeviceDetailViewController: 0x84a7340