Make up: Day 24 study python built-in functions corresponding to the output code

Absolute value 
Print (ABS (-1))

All () function is used for all elements in a given determination may be whether the iteration parameters iterable are TRUE, a return True, otherwise return False.
In addition to the elements is zero, empty, None, False are considered True.
print (all ( "djkjkd") )

whether any () function is used to determine whether a given parameter may be iteratively iterable all False, False is returned, if there is a True, True is returned.
In addition to the elements is 0, empty, FALSE are considered TRUE.
print (any ([1,2,3,0]) )


is the binary conversion, bin () returns an integer or a long integer long int int binary representation.
Print (bin (. 3))

BOOL () function for the given parameter to a Boolean type, without parameters, return False.
Print (BOOL ( ""))
Print (BOOL (None))
Print (BOOL (0))

dict () function is used to create a dictionary.
print (dict ()) # Create an empty dictionary Results} {

Print (dict (A = 'A', B = 'B', T = 'T')) # incoming keyword results: { 'a': 'a ',' b ':' b ',' t ':' t '}

print (dict (zip ([ ' one', 'two', 'three'], [1, 2, 3,4]))) # match is short, the way to construct a mapping function dictionary Results: { 'one' :. 1, 'TWO': 2, 'Three':. 3}

Print (dict ([( 'One',. 1), ( 'TWO', 2), ( 'Three',. 3)])) # iterables results embodiment constructed dictionary: { 'one':. 1, 'tWO': 2, 'Three':}. 3


ZIP () function is used to be the object as a parameter the iteration, the corresponding element of the object packed into a meta group, and then return the object of these tuples, the benefits of doing so is to save a lot of memory.
We can use the list () to convert the output list. If the number of elements of each iterator inconsistency, the shortest length of the object list is returned the same,

A = [l, 2,3]
B = [4,5,6]
C = [4,5,6,7,8 ]
zipped = ZIP (a, B) # returns an object
print (zipped) # the result is zipped address: <ZIP Object AT 0x00FC2440>
Print (list (zipped)) # list () into a list [(1, 4 ), (2, 5), (. 3,. 6)]
Print (list (ZIP (a, C))) # number of elements in line with the shortest list, [(1, 4), (2, 5), ( 3,



print (dir ([])) # view the list of methods

divmod () function of the divisor and the remainder operation result combined, returns a tuple containing the quotient and remainder of (A // B, A% B)
Print (divmod (. 8 2)) # use place: a page displaying a few. Results: (4, 0) has 4 represents an

eval () function is used to perform a string expression, and returns the value of the expression.
Print (the eval ( "*. 4. 1 + 2/2"))

filter () function is used to filter sequences, filtered ineligible element returns a list of qualified new elements.
The receiving two parameters, as a function of a first, a second sequence, each element of the sequence as an argument to a function arbitrates, then return True or False, and finally returns True new elements into the list.
filter (function, iterable) #function: judging function. iterable: iterables.

float () function is used to convert the integer to floating point and string.
print (float (10)) # Results: 10.0
Print (a float ( "123")) # Results: 123.0

# formatting functions, the format


# frozenset () Returns a collection of frozen, can not set any elements added or deleted after freezing.
a = frozenset (range (10) ) # generates a new set of immutable
Print (A) #frozenset ([0,. 1, 2,. 3,. 4,. 5,. 6,. 7,. 8,. 9])

B = frozenset ( 'runoob') # create immutable collections
Print (B) #frozenset ({ 'U', 'n-', 'O', 'R & lt', 'B'})

Globals () function returns the current position of all of the global variables to the dictionary type.

hash () takes an object for acquiring (string or numeric values) hash value. hash () function may be applied numbers, strings, and the object can not be directly applied to the List, SET, Dictionary
hash () function regardless of how long the object character, hash values returned are fixed length, it is also used to verify whether a third-party program (Trojan) modified during transmission,
if the program (character) is modified hash value in the transmission process that is changing, if not modified, the hash value and the hash value of the original agreement, as long as the verification hash value to verify whether the match with a Trojan horse program (virus).

print (hash ( 'test') ) # string
print (hash (1)) # digital
print (hash (str ([1,2,3 ]))) # set
print (hash (str (sorted ( { '1 ': 1})))) # dictionary

help () function is a function for viewing or use of the module in detail.
print (help ( 'sys') ) # sys module See help
print (help ( 'str') ) # view data type str help
a = [1,2,




print (hex (255)) # results 0xFF

# ID () function is used to obtain the memory address of the object.
= A 'runoob'
Print (ID (A))

Guess you like

Origin www.cnblogs.com/jianchixuexu/p/11546282.html