作者:额外的房间 | 来源:互联网 | 2023-10-16 19:21
目录
- 4.1. type 数据类型检测
- 4.2. String
-
- 4.2.1. String function
-
- 4.2.1.1. str.find()
- 4.2.1.2. str.find()
- 4.2.2. Convert str to bytes in python
- 4.2.3. String format
- 4.3. Array
-
- 4.3.1. split / join
- 4.4. Datetime
-
- 4.4.1. datetime
- 4.5. bytes 类型
-
- 4.5.1. BOM头
- 4.5.2. replace
- 4.5.3. pack/unpack
http://docs.python.org/library/types.html
>>> type( [] ) == list True >>> type( {} ) == dict True >>> type( "" ) == str True >>> type( 0 ) == int True >>> class Test1 ( object ): pass >>> class Test2 ( Test1 ): pass >>> a = Test1() >>> b = Test2() >>> type( a ) == Test1 True >>> type( b ) == Test2 True >>> type( b ) == Test1 False >>> isinstance( b, Test1 ) True >>> isinstance( b, Test2 ) True >>> isinstance( a, Test1 ) True >>> isinstance( a, Test2 ) False >>> isinstance( [], list ) True >>> isinstance( {}, dict ) True
>>> a = [] >>> type(a) >>> f = () >>> type(f)
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。