:
Install PIP:
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
Take:
Raspberry Pi B +: less than 2 minutes
Raspberry Pi 2: Less than 30 secondsStep 7:
Install Virtualenv and Virtualenvwrapper
$ sudo pip install virtualenv virtualenvwrapper
Then, update the ~/.profile
' in [623]:s.title () out[623]: ' Test ' in[624]:s.center (out[624]: ' test ' in[625]:s= ' Hahahahhehe ' in [626]:s.strip () out[626]: ' Hahahahhehe 'list, tuple, string, bytes, ByteArrayare sequentially stored, sequentially accessed, and are iterative objects that can be accessed through an indexIn [629]: List (enumerate ([+)]) out[629]: [(0, 1), (1, 2), (2, 3)]in [630]: LST = list (range) in [631]: lst
A dictionary of Python Learning Notes (v) 2Often used in practical programming.Example 1:copy
>> ad = {"name": "WTF", "hig": "180"}>> BD = AD>> BD{' name ': ' WTF ', ' hig ': ' 180 '}>> ID (AD)4539954352>> ID (BD)4539954352Description: An object affixed with two tags, using the assignment to achieve the so-called "fake copy."If you use Copy ()>> cd = Ad.copy ()>> CD{' name ': ' WTF ', ' hig ': ' 180 '}>> ID (CD)4541831160Description: The CD o
DescriptionWhile using Python, we may need to use some other functions that others have written in addition to the built-in functions. Or the code we write is also expected to be available to others. To implement such a function, we need to define our own modules as follows:STEP1: Create a new py fileFirst we save the function of the printed list written in the previous chapter as a. py file, assuming I save it here as kider.py.1 """
as E: 6 print (" unicodeerror ") The second one except is never caught UnicodeError , because UnicodeError ValueError the subclass, if any, is also captured by the first one except .6, try...except There is a huge advantage of capturing errors, that is, you can cross multiple calls, such as function main() calls, foo() foo() calls, the result is bar() bar() wrong, at this time, as long as the main() capture, you can handle1 defFoo (s):2 ret
structureData structures only statically describe the relationships between the elements of a dataset.Efficient programs require the design and selection of algorithms based on data structures.program = data structure + algorithmConclusion: The algorithm is designed to solve the practical problem, and the data structure is the problem carrier that the algorithm needs to deal with. 7. Abstract data typeAn abstract data type (ADT) means a mathematical
The teacher is using Python 2, but I think I now learn to learn a new bit better, 2 and 3 said the difference is quite big, so two versions are installed, their own learning when using 3, run the program with 2.
My Computer is Win 7, now the system is called by default is
features and techniques in front of them.
1.15 Leveling list:
>>> a = [[1, 2], [3, 4], [5, 6]]
>>> List (itertools.chain.from_iterable (a))
[1, 2, 3, 4, 5, 6]
>>> sum (A, [])
[1, 2, 3, 4, 5, 6]
>>> [x for L in a for x in L]
[1, 2, 3, 4, 5, 6]
>>> a = [[[1, 2], [3, 4]], [
Chapter 2 and Chapter 3 in Dive into Python, divew.python
Example 2.1. odbchelper. py
def buildConnectionString(params): """Build a connection string from a dictionary Returns string.""" return ";".join(["%s=%s" % (k, v) for k, v in params.items()])if __name__ == "__main__": myParams = {"server":"mpilgrim", \ "database":"master", \ "uid":"sa", \ "pwd":"secret" } print buildConnect
We have learned the concept of variables in high school. For example: we make x = 100, then we can launch x*2 = 200Try this Python code below1 Import Turtle 2 3 turtle.shape ("turtle")4 x =5 Turtle.forward (x)6 turtle.left (7) , Turtle.forward (+x)8 9 Turtle.exitonclick ()Run the above code and the turtle will draw
Chapter 2 python data types section 1 numbers and string types
Is 123 the same as "123 "?
() [] {}
Computers are used to assist people. in programming, they also map real-world classifications for abstract analysis.
Number
String
List
Tuples
Dictionary
We can view some simple data types through data types. python will automatically identify the data types
>>>
, 7, 9]> y [1, 2, 4, 6, 7, 9] >>> x = y >>> x [1, 2, 4, 6, 7, 9] >>> y [1, 2, 4, 6, 7, 9]
The sorted function is used to obtain sorted list copies:
>>> x=[4, 6,
1, to determine whether each letter in a string is in another string, you can use the properties of the collection to solve, if the elements of the collection, if the update (update) is not added to the collection, then the length of the collection is the same as the original, if added, the length of the collection will increase' Ghost ' ' Hello, can you help me install ghost Windows XP system '>>> b_set = Set (b)>>> b_set.update (List (a))print len (b_set) = = Len (set (b)) True'abcostg'>>> b_
1. Brief description Python 's Running processbefore we say this question, let's start with two concepts, Pycodeobject and pyc files. The PYc we see on the hard drive naturally doesn't have to say much, and pycodeobject is actually the result of a Python compiler actually compiling it. Let's just get to the bottom of it and keep looking down. when the Python pr
out[]: Typein [+]: Age. __class__. __class__ out[]: Typein []: foo. __class__. __class__ out[]: Typein []: B.__class__. __class__ out[]: typeTherefore, the meta-class is the east of the object that created the class. Type is Python's inner Jianyuan class, of course, you can also create?? Meta-class.7.__metaclass__ PropertyYou can add the __metaclass__ property to a class when you define it.class Foo (object): __metaclass__ = something ...
SYS moduleThe SYS module provides a series of variables and functions for the Python runtime environment.1 #重点记忆2 sys.argv #命令行参数List, the first element is the program itself path 3 sys.exit (n) #退出执行的程序未见, exit normally exits (0), different from the loop break out of the Loop 4 Sys.path #返回模块的搜索路径, initialize using the value of the PYTHONPATH environment variable 5 6 #一般
same, this is the role of *1 for inch [(1,2,3,4), (5,6,7,8)]: 2 A,b,c=all[0],all[1:3],all[3]3 print(a,b,c)"Four: Append"1 a=b=[]2 b.append (3)print(A, b)45 a=[]6 b=[]7 b.append (8)print(a , b)The first piece of code, because A and B refer to the same object, by B in the original value up, and we will see the same effect through a. The second piece of co
character encoding, with 2 bytes representing a character,4. Please write out the number of digits of "Li Jie" that are encoded with utf-8 and GBK respectively.utf-8:48 bitGbk:32 bitWhat is the representation of 5.Pyhton single-line and multiline comments respectively?Single-line Comment: #Multiline Comment: "" "6. What are the considerations for declaring variables?Python, like most other languages, has l
2.2 To filter specific rows:
A value in a row satisfies a condition
Values in rows belong to a collection
A value in a row matches a pattern (that is, a regular expression)
2.2.1: Values in rows are satisfied with a condition:
Basic Python version:
1 #! /usr/bin/env Python32 ImportCSV3 ImportSYS4 5Input_file = sys.argv[1]6Output_file = sys.argv[2]
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.