Let
x = [1,2,3]
然后在ipython中,我得到了以下结果。
> In [8]: type(x)
Out[8]: list
>
> In [9]: print(type(x))
<class 'list'>
为什么 print(type(x))
不只打印列表,而是多了一些类的信息?
相关问题是,如何显示输出结果?
type of x is; list
print(' x的类型是: ', type(x))
不能实现这个功能,因为它会得到额外的类信息,如下所示:
In [2]: print(' type of x is: ', type(x))
type of x is: <class 'list'>