Alibabacloud.com offers a wide variety of articles about python delete item from list, easily find your python delete item from list information here online.
Introduction to Python list, pythonlist
The variable data type [add, delete, modify, and query can be performed] list of a set of Ordered items can contain any data type, you can also include another list [any combination of nesting]. The
The following is a list of Python data types. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at it with Xiaobian.
I. basic data types
Integer: intString: str (note: \ t is equal to a tab key)Boolean value: boolList: list (set of elements)List []Ancestor: tupleAnces
The derivation of comprehensions (also known as analytic) is a unique feature of Python. Derivation is the structure of another new data series that can be built from one data series.
List-derived
Dictionary (dict) derivation formula
Set (set) derivation
List derivation one, use [] to generate listBasic format for inch if the conditio
composition, which uses one of our cyclic variables (x+10). And then we should now look at the part of a for loop header that declares the loop variable and an iterative object (for x in L)
To run the expression, Python executes an iteration through L within the interpreter, assigns x to each element in order, and collects the result of the expression on the left side of each element's run. The list of res
negative, start and end are negative to indicate from right to left, count from 1, step is negative to reverse -common list-related functions -len (a_list): Return list length -a_list.append (new Element): Add new element to end of list -A_list.extend (anoth Er_list): Add Another_list to the end of a_list, you can use + = to achieve the same effect, a_list + =
This paper deeply analyzes the application of dict,set,list,tuple in Python and its corresponding example, which helps readers to master the concept and principle. Specifically as follows:
1. Dictionary (dict)
Dict surrounded by {}Dict.keys (), Dict.values (), Dict.items ()Hash (obj) returns the hashed value of obj if the return represents a key that can be used as a dictDel or dict.pop can
The differences between the ancestor, list, and dictionary in Python are analyzed.
1. list)
List is the data structure that processes a group of ordered projects. You can store a series project in a list.
The items in the list sho
). Raises indexerror If list is an empty or index is out of range. (L.pop (index))-> item-Delete and return the item index (default). The Indexerror is presented if the list is empty or the range of the index. ) "" "Pass def Remove (self, value): # Real signature unknown;
This paper analyzes the application of dict,set,list,tuple in Python and its corresponding examples, which can help readers grasp the concept and principle. Specific as follows:
1. Dictionary (dict)
Dict surrounded by {}Dict.keys (), Dict.values (), Dict.items ()Hash (obj) returns the hash value of obj if it returns a key that can be used as a dictDel or dict.pop can d
map function:
Prototype: Map (function, sequence), which is to map a list to another list,
How to use:
def f (x):
Return x**2
L = Range (1,10)
Map (f,l)
OUT[3]: [1, 4, 9, +, BA] reduce function
Prototypes: Reduce (function, sequence, startvalue), which is to generalize a list into one output,How to use:
def f2 (x,y):
Return X+y
Reduce (f1,l)
OUT[7]: 45
Reduce (f
an integral integer
Float (2) # Convert to floating-point float
Long ("23″") # converted to long integer long integers
STR (2.3) # converts to string strings
Complex (3, 9) # returns complex number 3 + 9i
Ord ("A") # "a" character corresponding value
Chr (65) # Number 65 corresponds to the character
UNICHR (65) # VALUE 65 corresponds to the Unicode character
BOOL (0) # converted to the corresponding true and False value, in Python, 0 is equivalent
Data type number引号: 123 数值 ‘123‘ 字符串 整数:ini long 范围:(-2**31 - 2**31) num = 123 长整型 long (L) num = 123L浮点型:float复数型:SequenceString, list, tuple all belong to sequenceThe two main features of a sequence are index operations and slicing operations
Index operations can fetch a specific item from the sequence
Slice operations can get a slice from the sequence, which is
, ' everyday ', 0.618, True], 1th element has been changed from 365 to 123.3. Adding elements to the listThe list has a Append method that can add elements. Take the list of L as an example, the method to invoke is:L.append (1024)Output L, you will see [123, ' everyday ', 0.618, True, 1024],1024 was added to the L and became the last element. (The first element was changed to 123 in the previous step)You ca
, [], None]) # is there any one element equal to the true valueSorted ([1,5,3]) # Returns the sequence of the positive sequence, i.e. [1,3,5]Reversed ([1,5,3]) # Returns the sequence of the reverse order, i.e. [3,5,1]Class, Object, property# define ClassClass Me (object): def Test (self): print "hello!"Def new_test ():Print "New hello!"me = Me ()Hasattr (Me, "Test") # Check if the Me object has a test propertyGetAttr (Me, "test") # Returns the Test propertySetAttr (Me, "test", New_test
It's easy to create lists and dictionaries in Python, and here's a summary of their common methods.1. Create a listMyarry = ["one""" "" ""three"]There are many ways to access data in a list
Print (Myarry) will output all the data
Myarry[:] This will output all the data, if you want to output only a portion can be like this myarry[1:2] will be "two" element output
You can directly use the su
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.