Deepin Linux Desktop, screenshot tool Profiling (v) Python-lambda, list, dictionary__linux

Source: Internet
Author: User


Lambda expression, this bird thing is to define a function in one line of statements.


Http://woodpecker.org.cn/diveintopython/power_of_introspection/lambda_functions.html

>>> def f (x):
...     Return x*2 ...     
>>> F (3)
6
>>> g = lambda x:x*2  >>> g (3)
6
>>> (lambda x:x*2) ( 3) # 6

The List is the most frequently used data type in Python.

http://woodpecker.org.cn/diveintopython/native_data_types/lists.html#d0e5762

#/usr/bin/env python

li = []
print Li
li.append (' Sam ')
print Li
li.insert (1, ' Hello ')
Print Li
li.extend ([' Hi ', ' Tom '])
print Li
li.remove (' Hi ')
print Li
print li.index (' Sam ')

Dictionary is one of the built-in data types of Python, which defines a one-to-one relationship between keys and values.
http://woodpecker.org.cn/diveintopython/native_data_types/index.html#d0e5309

DIC = {}
dic["1"] = "2"
dic["2"] = 2
dic[1] = 2
print dic
del dic["1"]
print dic
dic.clear () C7/>print DIC



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.