Python intrinsic and anonymous functions

Source: Internet
Author: User
Tags ord pow vars

A built-in function

  

# Print (ABS ( -1)) # Print (All ([up to, ' a ', None]) # Print (All ([])) #bool值为假的情况: None, Empty, 0,false# # Print (any ([])) # Print ( [', None,false])) #True # Print (Any ([", None,false])) #False # Print (Any ([', none,false,1])) #True #bin,oct,hex# print (BIN) # Print ( Oct (Ten)) # print (hex) #bytes #unicode----encode----->bytes# print (' Hello '. Encode (' Utf-8 ')) # Print (bytes (' Hello ', encoding= ' Utf-8 ')) #callable # print (callable (bytes)) # Print (callable (ABS)) #chr, ord# print (CHR) # Print ( CHR) # Print (Ord (' # ')) #内置函数, also known as the Factory function # int# x=1 #x =int (1) # Print (type (x)) # X=int (2) Complexfloatstrlisttupledictset #可变集合frozenset #不可变集合 # s={1,2,3,4} #s =set ({1,2,3,4}) # Print (type (s)) # # S1=frozenset ({1,2,3,4}) # Print (Type (S1)) #dir # Import sys# # sys.path# # sys.argv# print (dir (sys)) #divmod # Print (Divmod (10,3)) # Print (Divmod (102,20)) #enumerate # l=[' A ', ' B ', ' C ']# res=enumerate (L) # for I in res:# print (i) # for Index,item in Enumerate (l): # print (Index,item) #globals, Locals #查看全局作用域和局部作用域 # Print (Globals ()) #hash # Print (HasH (' abcdefg123 ') # Print (hash (' abcdefg123 ')) # Print (hash (' abcdefg123 ')) # Print (hash (' abcdefg123 ')) #给函数加文档解释, use single quotes, Double quotes, three-quote def func (): # ' # ' # Test Function #: return: # ' pass# print (Help (func)) #id: Is the function of the Python interpreter, it only reflects the change Volume in memory address # but not real memory address # x=1# print (ID (x)) # def func ():p ass# Print (func) # Print (func) #isinstance # x=1# Print (type (x) is int) # Print (Isinstance (x,int)) #x =int (1) #迭代器iternext #len#max# print (max ([1,2,3,10])) # Print (max ([' A ', ' B ']) # print ( MIN ([1,2,3,10])) #pow # Print (POW (3,2,2)) #3 **2%2#range# #repr, str# print (Type (str (1)) # Print (Type (repr (1)) # reversed# l=[1, ' A ', 2, ' C ']# print (list (reversed (L))) # Print (L) #slice # l=[1,2,3,4,5,6]# print (L[0:4:2]) # # S=slice ( 0,4,2) # Print (L[s]) #sorted # l=[1,10,4,3,-1]# print (sorted (l,reverse=true)) #sum # Print (sum ([1, 2,3]) # # print (SUM (i For I in range) #vars # import m1# print (VARs (m1) = = m1.__dict__) #zip: Zip # s= ' hellosssssssssssssssss ' # l=[1,2,3,4,5]## Print (list (Zip (s,l))) #__import__import sys# m_name=input (' Module>>:') # if m_name = = ' sys ': # m=__import__ (m_name) # print (M) # print (M.path) # # sys=__import__ (' sys ') # print (SYS) #rou Ndprint (Round (3.565,2)) print (round (3.555,2)) #filter, map,reduce focus #max min sorted# Object-oriented objectsuper# __dict__ isinstanceissubclassclassmethodstaticmethodpropertydelattrhasattrsetattrgetattr# Understanding Compileevalexec

Two anonymous functions

  

def func (x,y,z=1):    return x+y+z# Print (func) # Print (func) #匿名函数: 1. No Name 2: The function body comes with return# print (lambda x,y,z=1: X+Y+Z) F=lambda x,y,z=1:x+y+zprint (f) Print (f (+)) # x=1# # print (x) # Print (1) #匿名函数的应用场景: #应用于一次性的场景, temporary use

  

Python intrinsic and anonymous functions

Related Article

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.