我对Python还很陌生,所以如果我遗漏了一些明显的东西,请原谅。最初我有一个由collections.namedtuple集合. 据我所知,recordtype可以作为一个临时替代品,来替代那些想要一个可变的namedtuple的人。但是当我从这个代码开始:
class SplitResultsContainer(collections.namedtuple('SplitResultsContainer', _URI_COMPONENTS)):
对于此代码:
class SplitResultsContainer(recordtype.recordtype('SplitResultsContainer', _URI_COMPONENTS, default=None)):
我的一个测试失败了:
self.assertEquals(splituri('foo://example.com:8042/over/there?name=ferret#nose'), ('foo', 'example.com:8042', '/over/there', 'name=ferret', 'nose'))
AssertionError: SplitResultsContainer(scheme=foo, authority=example.com:8042, path=/over/there, query=name=ferret, fragment=nose) != ('foo', 'example.com:8042', '/over/there', 'name=ferret', 'nose')
我正在创建一个URI解析器来自学Python。任何关于元组为什么与我测试中的记录类型不匹配的帮助都会非常有用,谢谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐