我有这个方法:
def split_pointer_part(self, line):
self.before_at, self.after_at = line.split('@', 1)
return self.before_at, self.after_at
这是有效的,但是当我对其运行此测试时:
def test_split_pointer_part(self):
line = '13797906 23 n 04 flood 0 inundation 0 deluge 0 torrent 0 005 @ 13796604 n 0000 + 00603894 a 0401 + 00753137 v 0302 + 01527311 v 0203 + 02361703 v 0101 | an overwhelming number or amount; "a flood of requests"; "a torrent of abuse"'
result = self.wn.split_pointer_part(line)
answer = ('13797906 23 n 04 flood 0 inundation 0 deluge 0 torrent 0 005',' 13796604 n 0000 + 00603894 a 0401 + 00753137 v 0302 + 01527311 v 0203 + 02361703 v 0101 | an overwhelming number or amount; "a flood of requests"; "a torrent of abuse"')
self.assertEqual(len(result), 2)
for r, a in zip(result, answer):
self.assertEqual(r, a)
这是我得到的错误:
self.before_at, self.after_at = line.split('@', 1)
ValueError: need more than 1 value to unpack
我知道我应该在某个地方使用 argv 我只是不知道如何在这种情况下使用它。