python中的非类型错误

2024-05-12 18:10:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我运行这段代码,但是我得到了typeError:'NoneType'对象不可读取 问题是什么??在

import bibtex
import unittest

class TestAuthorExtract(unittest.TestCase):
   def setUp(self):
       self.simple_author_1 = "Smith"

   def test_author_1(self):
       # Test only surname
       (Surname , FirstNames) = bibtex.extract_author(self.simple_author_1)
       self.assertEqual((Surname , FirstNames) , ("Smith", ""))

if __name__=='__main__':
    unittest.main()

以下是错误消息:

^{pr2}$

Tags: 对象代码importselfmaindefunittestbibtex