Python path-built-in functions

Source: Internet
Author: User

  1. ABS (val) >>> absolute value of Val
  2. All (iterable) >>> returns True if all of the elements in the object can be iterated, and false is returned by no
  3. Any (iterable) >>> returns True if there is an element in an iterator object that is true, if it returns false otherwise
  4. ASCII (object) >>> convert a printable object to a string (rarely used)
  5. Bin (x) >>> Convert an integer x into binary
  6. BOOL ([x]) >>> convert list, number to bool value
  7. Bytes (str,encoding) >>> converts a string to binary, and the element cannot be modified
  8. ByteArray (str,encoding) >>> converts a string into a byte array, and can modify the element
  9. Callable (f) >>> determine if f can be called (F can be appended with parentheses, which can be called)
  10. Chr (i) >>> converts the number I to the character corresponding to the ASCII code
  11. Ord (c) >>> converts the character C to the encoding corresponding to the ASCII code
  12. Compile (STR1,STR2,STR3) >>> compiles the code in the string str1 with the execution specified in the string STR3, and saves the error message in str2 specified file if there is an error example: c= compile (Code, " Err.log "," exec ") if you want to perform a compile return result on exec (c)
  13. EXEC >>> Converts a string expression into code and executes the code
  14. Dir (c) >>> View all methods in Type C
  15. Divmod (A, B) >>> returns the quotient and remainder of A/b as tuples
  16. Enumerate () >>> convert list to enum type (see above for details)
  17. eval (expression) >>> convert string expression to code
  18. Filter (function,iterable) >>> filters out the data in iterable in the logic of the function and returns it as an iterator (for loop output) For example: res = filter (lambda-n >5,range (Ten)) >>>6~9
  19. Map (function,iterable) >>> operations with the logical iterable of a function and returns an iterator to the result for example: res = map (lambda n:n*n,range) > >>0,1,4,9,..., 81 equivalent to [N*n for N in range (10)]
  20. Format (*args,*kwargs) >>> replace placeholders (for example {0}, {1}) in the string with parameters in format (same as the format method in str type)
  21. Frozenset ([item1,item2,....]) >>> Make a collection immutable
  22. Globals () >>> returns all global variables under the current file
  23. Hash (str) >>> convert str string to corresponding hash value
  24. Hex (n) >>> convert a number to hexadecimal
  25. Locals () >>> returns the local variable in the child statement block where the method resides
  26. Max (iterable) >>> returns the maximum value in iterable
  27. Min (iterable) >>> returns the minimum value in iterable
  28. Oct (x) >>> convert number x to octal
  29. Pow (b) >>> returns the B-side of a
  30. Reversed (seq) >>> Reverse
  31. Round (f) >>> floating-point number f reserved two decimal places
  32. Slice (start,stop) >>> slice equivalent with [start,stop]
  33. Sorted (Iterable[,function,key]) >>> sort an iterative object with a logical function for example: a = {6:2,8:0,1:4,5:6} sorted (A.items,key = Lambda X:x[1]) >>> sort dictionaries in order of dictionary values
  34. SUM (iterable) >>> sum the list, etc.
  35. Zip (A, b) >>> A/b for one by one stitching
  36. __import__ (str) >>> import module with STR as module name

Python path-built-in functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.