我一直在寻找其他帖子,但找不到我的问题的答案。
class Libro():
def __init__(self):
self.autor = ""
def setAutor (self, new_autor):
regex = "[^\d\s]+( [^\d\s]+)*"
if re.fullmatch (regex, new_autor):
self.autor = new_autor
else:
print("\n\n ****** ERROR ******")
self.autor = ""
libro = Libro()
class Comic(Libro):
def __init__(self):
Libro.__init__(self)
libro.setAutor(self)
comic = Comic()
那是我的错误,我不知道如何解决
In <module>
comic = Comic()
In __init__
libro.setAutor(self)
In setAutor
if re.fullmatch (regex, new_autor):
In fullmatch
"return _compile(pattern, flags).fullmatch(string)"
TypeError: expected string or bytes-like object
非常感谢您!