Get more information Welcome to my website or csdn or blog park
Recently put my Python notes, hoping to help others, this is the first lesson, installation of the introductory article;
Install Python under Windows
1, download, download from here: [download link] (http://python.org/download/)
2, download the version of Windows, download completed, double-click Open, and then step by step installation.
3, the environment variable add: I was installed in the "D:\Python33",
So right-click "My Computer"-"Properties-" Advanced environment Settings-"advanced-" Environment variables
Locate the path in the system variable, click Edit to join; D:\Python
4. You can now enter Python directly under command prompt cmd, display your version number after entering Python, and enter the python command line
5, of course, can also click: Start Menu "All Programs" "Python" python (Command line)
Install Python under Ubuntu
1 installation, with PPA available (supports all Ubuntu versions and derivative systems), open terminal, enter command:
sudo add-apt-repository ppa:fkrull/deadsnakes
2 Update Source
sudo apt-get update
3 Installing Python3.3
sudo apt-get install python3.3
4 setting Python3.3 as the default command (Ubuntu is not up-to-date)
Rm/usr/local/bin/python
Ln-s/usr/local/bin/python3.3/usr/local/bin/python
5 Enter Python in terminal, display your version number, and go to the Python command line
First program Hello World
>>>print ‘hello world‘hello world
Basic operations
1, you can enter the command directly in the Python interactive mode, you can also create a. py file through the command Python hello.py;
2. Name = Raw_input (' Please enter your name: ') entered into the name variable
Int (raw_input (' Please enter your name: ') is converted to an integer, and ord (' A ') is converted to an integer, and Chr (65) is converted to a character
3, the beginning of the # is a note;
4, there are built-in functions, and introduction modules: Import Math. Then Math.floor (32.9) or from math import sqrt sqrt (9) =3 direct call;
5. When the statement ends with a colon ":", the indented statement is treated as a block of code
6, integers and floating-point numbers are the same; the string can only be enclosed in single or double quotation marks, with the escape character \ ' represented when the string contains both single quotation marks and double quotation marks, and bool True False: and (&) or (|) not (~); Python also allows R "to represent" The internal string is not escaped by default
7, the statement is too long line-wrapping can be "'" contains
>>>print‘‘‘line1line2line3‘‘‘line1line2line3
8. None represents null value
9, the variable itself type is not fixed language called Dynamic language, such as a=123 a= ' aba ' Python is static language;
10, when using Unicode through U ' Chinese ' u ' abc '. Encode (' Utf-8 ') into the format of utf-8; Len (U ' abc ') obtains the string length; ' abc '. Decode (' Utf-8 ') converted to Unicode;
11, as you may have guessed, the% operator is used to format the string. Inside the string,%s is replaced with a string,%d is replaced with an integer, there are several% placeholder, followed by a number of variables or values, the order to correspond well. If there is only one%, the parentheses can be omitted.
12, Print type (3.0) Get the Model:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Software installation for getting started with Python