Python Temporary notes

Source: Internet
Author: User

Features of dynamic language Python

Python2 Enter an anonymous function to execute directly

# Coding=utf-8 def Test (A, B, func):     = Func (A, b)    return= input ("pleaseinput a fun::"  )    #Please input a fun::Lambda x,y:x+y
Print (Test (Ten, func_new)) #30

Python3 will convert all input inputs into strings, so the Eval method is required to convert them.

def Test (A, B, func):     = Func (A, b)    return= input ("pleaseinput a fun::")  # the value accepted by input in Python3 all becomes string   type Please input a fun::lambda x,y:x+y
Func_new = eval (func_new)  #  Execute string python statement   print(Test (+, func_new)) #30

Python Temporary notes

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.