七十六、type类
1、定义:
class type(object) | type(object) -> the object's type | type(name, bases, dict) -> a new type
2、解释:用于查看一个对象的类型(非常常用)或者创造一个新的类对象(可以理解成用于创造类对象(类也是对象)的元类)。
3、举例:
>>> type(1)
<type 'int'>
>>> type("a")
<type 'str'>
>>> type([])
<type 'list'>
>>> class A(object):
... pass
...
>>> A
<class '__main__.A'>
>>> type('A', (), {})
<class '__main__.A'>
七十七、unichr方法
1、定义:
unichr(...)
unichr(i) -> Unicode character
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.
2、解释:返回一个数字的unicode 字符串
3、举例:
>>> unichr(1)
u'\x01'
>>> unichr(16)
u'\x10'
>>> unichr(160000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
Copyright © 2021.aoyanming个人博客站
发表评论