Python Learning Day4

Source: Internet
Author: User

function Adorner

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m00/82/59/wkiom1drbtacnuanaag4-owfb8u045.png-wh_500x0-wm_3-wmp_4-s_1153846836.png "title = "Untitled.png" alt= "Wkiom1drbtacnuanaag4-owfb8u045.png-wh_50"/>

Built-in functions
    • Compiling a string into Python code

# s = "Print (123)" # Compile (S, "<string>", "exec")
    • Execute code, string, expression

# exec ("Print (1+2+3)")    #代码与字符串都可以执行, but no return value (no return value) # print (eval ("1+2+3"))   # You can execute an expression that returns the execution result as a return value (with a return value) 
    • Help (list) #查询class的具体使用方法

    • object is an instance of the class

# string = "Zshaox" #对象string is an instance of STR class
    • Determine if an object is an instance of a class

# Isin = isinstance (String, str) #isinstance object is an instance of Class # print (ISIN)
    • Enumerate traversal of array/list information, print subscript

# for Key,value in enumerate ([1, 2, 3]): # Print (key, value)
    • Filter loops and Map loops

      The filter function returns true to add elements to the result
      Map adds the function return value to the result

tu =  (1, 2, 3, 4, 5,  ' 1 ',  ' 2 ',  ' 3 ') # def f2 (argv): #      if argv > 2:#          return true#ret = filter (F2,&NBSP;TU) #filter循环第二个参数, the element of the second parameter that can be traversed as a parameter (function), the execution function returns TRUE, The parameter is passed into  ret ret = filter (Lambda a: type (a)  == int, tu) ret =  The list (Ret) print (tuple) #map循环第二个参数, which passes the traversed elements in the second argument as arguments, executes in a function, and returns the value to the RET ret = map (lambda a:  a + 100, ret) Print (list (ret)) 
    • Len () calculates the length of a character by default in Python3, and cannot calculate the length of a character in python2.7, only the length of a byte

    • Min () #找最小值

    • Max () #找最大值

    • SUM () #求和


Python Learning Day4

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.