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.
可以说' a'是某种类型(我想知道!)
a
做这样的事情:
b = str(a)
这应该有利于提高TypeError
TypeError
没有使用 引发 TypeError 的内置 Python 类str,但您可以定义一个自定义类:
str
class Foo(object): def __str__(self): raise TypeError('Can not by stringified') foo = Foo() b = str(foo)
提出一个TypeError。