当前位置:网站首页>Global function Encyclopedia
Global function Encyclopedia
2022-07-04 11:07:00 【It's a cinch!】
abs()—— The absolute value
max()—— Maximum
min()—— minimum value
sum()—— Sum up
pow()—— Power
len()—— Returns the object ( character 、 list 、 Tuples etc. ) Length or number of items
range()—— Create an integer list , Commonly used in for loop
reversed()—— Flip , Sorting is usually associated with sort() Use it with
round()——round(n),n It's odd , Follow the rounding ;n For the even , With 5 For the dividing line , Less than or equal to 0.5 Give up everything
——round(n,m) Yes n Round to m position
divmod()—— Combine the results of divisor and remainder operations , Returns a tuple containing quotient and remainder (a // b, a % b)
int()—— To integer
float()—— Convert to floating point
chr()—— Turn to character type
list()—— Create a list of
set()—— Create set
tuple()—— Creating a tuple
dict()—— Create a dictionary
type()—— View type
help()—— Check for a detailed description of the purpose of the function or module
str()—— Turn the object into a form suitable for human reading
ord()——ord() The function is chr() function ( about 8 Bit ASCII character string ) The pairing function of , It takes a string (Unicode character ) As a parameter , Return the corresponding ASCII The number , perhaps Unicode The number .
dir()—— Without parameters , Returns the variables in the current range , List of types of methods and definitions ; With parameters , Return the properties of the parameter , Method list
hex()—— To hexadecimal
bin()—— Change to binary
oct()—— Turn into eight entries
input()—— Accept a standard input data , Return to string type
delattr()—— Delete attribute
hash()—— Get an object ( String or number, etc ) Hash value of
memoryview()—— Returns the memory view object for the given parameter (memory view). So called memory view object , Wrap the data that supports the buffer protocol , Allows without the need to copy objects Python Code access .
all()—— Determine the given iteratable parameter iterable Whether all elements in are TRUE, If it's a return True, Otherwise return to False.( Except that the elements are 0、 empty 、None、False Outside is True.)
any()—— Determine the given iteratable parameter iterable Is it all False, Then return to False, If I have a theta True, Then return to True.( Except that the elements are 0、 empty 、False Outside is True.)
next()——next() Returns the next entry for the iterator ;next() Functions should be associated with iterators iter() Functions together .
iter()—— Generate iterators
slice()—— Implement slice object , It is mainly used for parameter passing in slice operation function
id()—— Get the memory address of the object
__import__()—— For dynamically loading classes and functions
hasattr()—— Determines whether the object contains corresponding properties
sorted()—— For all iterations (list、tuple) To sort objects in ascending order
list Of sort Method returns an operation on an existing list , And built-in functions sorted Method returns a new one list, Instead of operating on the basis of the original .
enumerate()—— For traversing a data object ( Such as : list , Tuples or strings ) Combined into an index sequence , List both data and data index , Generally used in for In circulation
staticmethod()—— The static return method of the function
bool()—— Converts a given parameter to a Boolean type , If there are no parameters , return False
eval()—— Remove the outer delimiter , Execute string expressions , And return the value of the expression .
open()—— Used to open a file , And return the file object , This function is used for processing files , If the file cannot be opened , Will throw out OSError.
Be careful : Use open() The function must ensure that the file object is closed , That is to call close() function .
open() A function usually takes two arguments : file name (file) And pattern (mode)
isinstance()—— Determine whether an object is a known type , similar type()
bytes()—— Back to a new bytes object , The object is a 0 <= x < 256 An immutable sequence of integers in an interval . It is bytearray The immutable version of .
complex()—— Create a value of real + imag * j To convert a string or number to a complex number . If the first argument is a string , You do not need to specify a second parameter
property()—— Return the property value in the new class
map()—— Map the specified sequence according to the function provided
repr()—— Convert the object to a form for the interpreter to read
ascii()—— Returns a string representing an object
ascii() Function similar to repr() function , Returns a string representing an object
zip()—— Take iteratable objects as parameters , Package the corresponding elements in the object into tuples , Then return a list of these tuples .
filter()—— For filtering sequence , Filter out the elements that do not meet the conditions , Returns an iterator object , If you want to convert to a list , have access to list() To convert . This accepts two parameters , The first one is a function , The second is the sequence , Each element of the sequence is passed as a parameter to the function for judgment , Then return True or False, And then it will return True Is placed in the new list .
classmethod()—— The function corresponding to the modifier does not need to be instantiated , Unwanted self Parameters , But the first parameter needs to represent the class itself cls Parameters , You can call the properties of a class , Class method , Instanced objects, etc
getattr()—— Return an object property value
globals()—— Returns all global variables of the current location in dictionary type
locals()—— Returns all local variables of the current location in dictionary type
frozenset()—— Returns a frozen collection , After freezing, no more elements can be added or removed from the collection
vars()—— Returns the object object Dictionary object for properties and property values
super()—— Call the parent class ( Superclass ) One way
callable()—— Check whether an object is callable . If you return True,object The call may still fail ; But if you go back False, Call object object It will never work
format()—— Enhance the function of string formatting . The basic grammar is through {} and : To replace the old %
issubclass()——issubclass(class, classinfo)—— Used to judge the parameters class Whether it is a type parameter classinfo Subclasses of
print()—— Enter data from keyboard
bytearray()—— Returns a new byte array . The elements in this array are mutable , And the range of values for each element : 0 <= x < 256
setattr()—— The corresponding function getattr(), Used to set property values , The attribute does not necessarily exist
object()————object() Function returns an empty object . You cannot add new properties or methods to this object . This object is the foundation of all classes , It has default built-in properties and methods for all classes .
compile()—— Compile a string into byte code
exec()—— Execute... Stored in a string or file Python sentence , Compared with eval,exec Can perform more complex Python Code .
边栏推荐
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- VPS安装Virtualmin面板
- SSH原理和公钥认证
- 守护进程Xinted和日志记录Syslogd
- Canoe-the second simulation project-xvehicle-1 bus database design (idea)
- Installation of ES plug-in in Google browser
- Digital simulation beauty match preparation -matlab basic operation No. 6
- [Galaxy Kirin V10] [server] iSCSI deployment
- Learning XML DOM -- a typical model for parsing XML documents
- Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
猜你喜欢
Climb Phoenix Mountain on December 19, 2021
F12 clear the cookies of the corresponding web address
SQL greatest() function instance detailed example
20 kinds of hardware engineers must be aware of basic components | the latest update to 8.13
Canoe test: two ways to create CAPL test module
[Galaxy Kirin V10] [desktop] FTP common scene setup
Take advantage of the world's sleeping gap to improve and surpass yourself -- get up early
Post man JSON script version conversion
Canoe - the third simulation project - bus simulation - 3-2 project implementation
Simple understanding of seesion, cookies, tokens
随机推荐
Elevator dispatching (pairing project) ②
Capl: timer event
Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
[test theory] test the dimension of professional ability
[Galaxy Kirin V10] [server] KVM create Bridge
Lvs+kept realizes four layers of load and high availability
Postman advanced
[Galaxy Kirin V10] [server] system partition expansion
Strings and characters
Performance test method
[Galaxy Kirin V10] [server] FTP introduction and common scenario construction
shell awk
Understanding of object
Summary of collection: (to be updated)
[Galaxy Kirin V10] [desktop] FTP common scene setup
Interview and lecture summary 1
Open the neural network "black box"! Unveil the mystery of machine learning system with natural language
Is Sanli futures safe? How to open a futures account? How to reduce the handling charge of futures at present?
Iterator generators and modules
QQ get group member operation time