Tag: It's complex function address strong Col SSG Logs iterate object
| Function (method) |
Function |
| Type () |
|
| ID () |
|
| List () |
|
| Tuple () |
|
| Dict () |
|
| STR () |
|
1.type (): Accepts an object as a parameter and returns its type. Its return value is a type object.
>>> Type (123) #整数<class 'int'>>>> Type ('Hello,world') #字符串<class 'Str'>>>> Type (12.2+1j) #复数<class 'Complex'>>>> Type (12.3) #浮点数<class 'float'>
>>> type ([1,2,3,4])#List<class 'List'>>>> type ({'name':'Kebi',' Age': 28})#Dictionary<class 'Dict'>>>> type ((1,2,3,4))#Meta-group<class 'tuple'>>>> type (True)#Boolean type<class 'BOOL'>
Type () as a type function, you can detect the types of all data. Common data types: integers, long integers, floating-point numbers, complex numbers, ganso, lists, dictionaries, strings, and Booleans
The object above is known by its return value as the type of the object, and the return value is a type object.
>>> type (Type (4))
<class ' type ' >
2.id (): The memory address of the object can be viewed.
>>> a = 10>>> B = 12>>> ID (a)1731224064>>> ID (b)1731224128
3.list (): Convert an Iterative object to a list
>>> List ('wo shi ni baba') List of #字符串 ———— ['W','o',' ','s','h','I',' ','N','I',' ','b','a','b','a']>>> List ((1,2,3,4,5) ) #元祖 List of ————— [1, 2, 3, 4, 5]
When a dictionary is used as a parameter to a list (), the key is extracted to form a list
>>> List ({'name':'Kebi',' Age':' -'})['name',' Age']>>> List ({'name':'Kebi',' Age':' -','Sex':'Women'})['name',' Age','Sex']
4.STR (): Converts the Obj object to a string.
>>> STR (123)'123'>>> STR ([1,2,3,4])'[1, 2, 3, 4]'>>> Str (1,2,3,4,5))'(1, 2, 3, 4, 5)'>>> Str ({'name':'Kebi',' Age':' -'})"{' name ': ' Kebi ', ' age ': ' + '}"
5.tuple (): Converts an iterative object into a meta-ancestor object.
>>> Tuple ('Hello,word') #字符串 ———— "Yuan zu ('H','e','L','L','o',',','W','o','R','D')>>> tuple ([1,2,3,4]) #列表 ———— "Yuan zu (1, 2, 3, 4)
String (tuple)--"tuple--" (list)--"(join) string
List ()
>>> SSG = tuple ('Hello,word')>>>SSG ('H','e','L','L','o',',','W','o','R','D')>>>"'. Join (List (SSG))'Hello,word'
Python common functions