Python is very hot, this year's study plan also has to learn python, this year's goal is to be able to use Python to do simple operation, can write simple crawler, strategy, can achieve this goal.
Because the goal is to write something first, so I do not need to understand Python particularly deep, follow the great god Liaoche Blog to learn python, while doing their own summary.
Data:
List
The list is similar to the C-language array, except that it can be nested and provides various interfaces.
# !/usr/bin/python classmates =[" hello ", " Zhang ", " Jingle ", " feiailing " ] Print Classmatesclassmates.insert ( 1, " jingledddddd " ) print classmates
1. Example classmates=[' 1 ', ' 2 ', ' 3 ']
2, support subscript access classmates[0], assignment or printing can be
3. Interface:
List number: Len (classmates) = 3 len (classmates[1]) = 1, first refers to the number of elements, and the second refers to the length of a string
Insert Classmates.insert (1, ' zhangjingle '), the first element refers to the subscript, the second is the value
Delete: Classmates.pop () classmates.pop (i)
Visit: classmates[0] classmates[1] clssmates[2], classmates[-1] classmates[-2],classmates[-3]
Tuple: Structure:
There are two main points:
1, after initialization can not be modified
2, when there is only one element need to add,
t = (' 1 ', ' 2 ')
t = (1,): is a tuple data type with only one element
t = (): parentheses
t= (1): 1
Condition Judgment:
if xx: print xxxxxxelif xxxxx: print aaaaa Else : Print XCCCCCCC
For loop:
sum = 0 for in range (101): = sum + xprint sum
While loop:
Note that there are colons: and Indentation, others are very simple
Data input:
Proper input 100 is an error, because the input is a string, if you want to judge with integers, you need to do a conversion.
Dict:
Similar to the map in C + +, set is a collection without duplicates.
d = {‘Michael‘: 95, ‘Bob‘: 75, ‘Tracy‘: 85}
To create a set, you need to provide a list as the input collection:
set([1, 2, 3])
Set has add and Rmove two method operations, there is a & operation between the set set and the set.
Function:
Define with Def,: Split, indent representation function body
def myprint (): Print " maindddddd " Myprint ()
Python Introductory article