Python built-in functions

Source: Internet
Author: User

1,help (i) Help

2,dir (), all variables and built-in variables for the current file

3,vars (), the value of all variables and variables in the current file, and the values of built-in variables and built-in variables

4,type (i), the type of the variable

5,import Temp Import module, the effect of multiple imports is imported only once.

6,reload (temp) can import modules multiple times

7,id (i), shows the memory address of the variable

cmp(2,3)

cmp ( 2 , 2 ) cmp ( 2 , 1 ) cmp ( 10 , 1 ) abs () bool () divmod () max () min () sum () pow ( 2 11 ) - - - - - - - - - - - - - - - - - - len () all () any () - - - - - - - - - - - - - - - - - - chr () ord () hex () oct () bin () - - - - - - - - - - - - - - - - - - print range ( 10 ) print xrange ( 10 ) for in xrange ( 10 ):      print i for k,v  in enumerate ([ 1 , 2 , 3 , 4 ]):      print k,v - - - - - - - - - - - - - - - - - - s = ‘i am {0}‘ print s. format ( ‘alex‘ ) str ( 1 ) - - - - - - - - - - - - - - - - - - def Function(arg):      print arg print apply (Function,( ‘aaaa‘ ))  #执行函数 print map ( lambda x:x + 1 ,[ 1 , 2 , 3 ])  #all print filter ( lambda x: x = = 1 ,[ 1 , 23 , 4 ])  #True序列 print reduce ( lambda x,y:x + y,[ 1 , 2 , 3 ])  #累加 = [ 1 2 3 ] = [ 4 5 6 ] = [ 4 5 6 ] print zip (x, y,z) - - - - - - - - - - - - - - - - - - #__import__() #hasattr() #delattr() #getattr() module  = __import__ ( ‘temp‘ ) print dir (module) val  = hasattr (module,  ‘version‘ ) print val - - - - - - - - - - - - - - - - - - #callable()      #函数、类必须要有 __call__ 方法 #compile #eval com  = compile ( ‘1+1‘ ,‘ ‘,‘ eval ‘) print eval (com) #exec语句 code  = "for i in range(0, 10): print i" cmpcode  = compile (code, ‘ ‘, ‘ exec ‘) exec cmpcode code  = "print 1" cmpcode  = compile (code, ‘ ‘, ‘ single‘) exec cmpcode - - - - - - - - - - - - - - - - - - #isinstance() #issubclass() #super() #staticmethod()

Python 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.