list do not necessarily require the same data type, and we can include all kinds of data in the list:>>> L = [‘Michael‘, 100, True]A list that doesn't have an element is an empty list.>>> empty_list = []8.2 Accessing the list by indexSince list is an ordered set, we can use a list to indicate from high to low the 3 students in the class:>>> L = [‘Adam‘, ‘Lisa‘, ‘Bart‘]So how do we get the names of the nth-named students from the list? The method is t
be of the same data type. We can include various types of data in the list:
L = ['Michael', 100, True]
A list that does not have an element is an empty list:
empty_list = []
# Print sequence table L = ['Adam ', 95.5, 'lisa', 85, 'bart', 59] print L
V. Accessing the list by index in Python
Because list is an ordered set, we can use a list to show three students in the course from high to low by score:
L = ['Adam', '
IOS NSDictionary and Model
This tutorial describes how to extend NSObject through runtime and assign values to the Model using dictionaries. This is a very useful technique.
Runtime details will be detailed later
Source code:
NSObject + Property. h and NSObject + Property. m
/// NSObject + Property. h // ModelValueTest1.0 /// Created by Lisa on 14-9-15. // Copyright (c) 2014 Lisa. all rights reserved. //
Neo4j getting started (iv): Cypher Query OptimizationFirst of all, it's still the same, clear all the content in the current database, clean up and start learning a new chapter.
Match (n)-[r]-(n1)
Delete r, n, n1
Match (n)
Delete n
Next, use the characters and contacts in the second blog:
CREATE (bradley: MALE: TEACHER {name: 'bradley ', surname: 'green', age: 24, country: 'us '})
CREATE (matthew: MALE: STUDENT {name: 'Matthew ', surname: 'cooper', age: 36, country: 'use '})
CREATE (
What is DictWe already know that list and tuple can be used to represent sequential collections, for example, the name of the class:[' Adam ', ' Lisa ', ' Bart ']Or the test results list:[95, 85, 59]However, to find the corresponding score according to the name, it is inconvenient to use two list to indicate.If you associate a name with a score, make a similar look-up table:' Adam ' ==> 95' Lisa ' ==> 85' B
Python's dict and set types
1. What Python is Dict
D = { ' Adam ': +, ' Lisa ': $, ' Bart ': ', ' Paul ': 75}
2. Python's Access Dict
D = { ' adam ': 59}print, ' Lisa ': $, ' Bart ': ' Adam: ', d[' Adam ']print ' Lisa: ', d[' Lisa ']print ' Bart: ', d[' Ba RT ']
3. Features of dict in Python
D = {
This article mainly describes the Python Dict and Set types.
Python Dict and Set types
1. what is dict in Python?
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 75}2. access dict with Python
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59}print 'Adam:', d['Adam']print 'Lisa:', d['Lisa']print 'Bart:', d
This tutorial describes the use of the runtime extension NSObject, can be directly in the dictionary to the model assignment, this is quite useful technology.PS: Details about runtime will be introduced in detail laterSource:Nsobject+property.h and NSOBJECT+PROPERTY.M nsobject+property.h// modelvaluetest1.0//// Created by Lisa on 14-9-15.// Copyright (c) 2014 Lisa. All rights reserved.//#import nsobject
implemented internally.TaskUse the For loop to iterate through the algebraic column 1-100 and print a multiple of 7.Reference code:For I in Range (1,101):If i%7==0:Print IIndex iterationsIn Python, iterations are always taken out of the element itself, not the index of the element. For an ordered set, the element is indeed indexed. Sometimes we really want to get the index in the for loop, what do we do?The method is to use the enumerate () function :In enumerate (L): ... Print index, '-',
Create list:l = [' Adam ', ' Lisa ', ' Bart ', ' gechong ', ' kongming ']Show List:l[0]Traversing List:print (L) and for loopsUpdate List:append () and insert () and direct assignmentDelete List:pop () and pop (n)List features:can add deleteLi = [' Adam ', ' Lisa ', ' Bart ', ' gechong ', ' kongming ']print (LI) for name in Li:print (name) Create Tuple:tu = (' Adam ', '
We already know that list and tuple can be used to represent sequential collections, for example, the name of the class:[' Adam ', ' Lisa ', ' Bart ']Or the test results list:[95, 85, 59]However, to find the corresponding score according to the name, it is inconvenient to use two list to indicate.If you associate a name with a score, make a similar look-up table:' Adam ' ==> ' Lisa ' ==> ' Bart ' ==> 59Give
This article extracts from the MU class net "The introduction of Python"1. Dict characteristicsDict is denoted by curly braces {} and then Key:value, written out. The last comma of a key:value can be omitted.①,dict search speed is fast , regardless of whether the dict has 10 elements or 100,000 elements, the search speed is the same . The search speed of the list decreases as the element increases. The disadvantage of Dict is that it takes up a lot of memory, and it wastes much content , the li
Python -- about dict, Python -- dict
This article is excerpted from MOOC getting started with Python.
1. dict features
Dict is represented by braces {}, and then written according to key: value. The last key: value comma can be omitted.
①,Fast dict search,No matter whether dict has 10 or 0.1 million elements, the search speed is the same.. The search speed of list gradually decreases with the increase of elements.
The disadvantage of dict is that it occupies a large amount of memory and wastes
', 'Jason', ['A', 'B'])>>> L = t[3]>>> L[0] = 122>>> L[1] = 233>>> print t(3.14, 'China', 'Jason', [122, 233])
This is because Tuple's so-called immutable refers to the immutable pointing position, because the fourth element in this example is not a basic type, but a List type, therefore, the position of the List pointed by t is unchanged, but the content of the List itself can be changed, because the allocation of the List itself in the memory is not continuous.
Dict
Dict is a very important d
fast, regardless of whether the dict has 10 elements or 100,000 elements, the search speed is the same. The search speed of the list decreases as the element increases.However, the dict search speed is not without cost, dict the disadvantage is that the memory is large, but also waste a lot of content, and the list is the opposite, the use of small memory, but the search speed is slowThe second feature of Dict is that the stored key-value sequence is not in order! This is different from list (D
is a dictionary, actually key-value key-value pairs, similar to HashMap, you can use curly braces {} to define a struct like a C language:>>> d = { ' Adam ': 75}>>>, ' Lisa ': $, ' Bart ': ', ' Paul ': ' Lisa ': ' Paul ' on the print d{' : "Adam": Up, ' Bart ': 59}You can see that the printed results are in key:value format, and the Len function can be used to calculate its length (List,tuple can als
actor table's actor_id field is the primary key. Table 20-7 Shared lock example for INNODB storage engine
Session_1
Session_2
mysql> Set autocommit = 0; Query OK, 0 rows Affected (0.00 sec) mysql> Select Actor_id,first_name,last_name from actor where actor_id = 178;+------ ----+------------+-----------+| actor_id | first_name | Last_Name |+----------+------------+-----------+| 178 | lisa | monroe |+----------+----
Tags: MySQL exclusive lock share lock1, Shared lock experimentSession1Build a table Lisa and insert data in Session1Mysql> CREATE table Lisa (name char (ten), age int (5));Mysql> INSERT into Lisa values (' Lisa ', ' 26 ');Add a shared lock to the age=26 lineMysql> set autocommit=0;Mysql> SELECT * from the
iterations are implemented internally.TaskUse the For loop to iterate through the algebraic column 1-100 and print a multiple of 7.Index iterationsIn Python, iterations are always taken out of the element itself, not the index of the element. For an ordered set, the element is indeed indexed. Sometimes we really want to get the index in the for loop, what do we do?The method is to use the enumerate () function :In enumerate (L): ... Print index, '-', name ... 0-adam1-lisa2-bart3-paulUsing
Slicing a listTaking a partial element of a list is a very common operation. For example, a list is as follows:>>> L = [' Adam ', ' Lisa ', ' Bart ', ' Paul ']What should I do if I take the first 3 elements?Stupid way:>>> [l[0], l[1], l[2]][' Adam ', ' Lisa ', ' Bart ']The reason why is stupid is because of the extension, take the first n elements will be out of the way.Take the first N elements, which are
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.