Python Learning Notes (ii) Python syntax _1

Source: Internet
Author: User

[Email protected] ~]# Ipythonin [1]: Import platformin [2]: Print Platform.uname () (' Linux ', ' kaibin.test1 ', ' 2.6.32-431. El6.x86_64 ', ' #1 SMP Fri 03:15:09 UTC ', ' x86_64 ', ' x86_64 ') in [3]: Dir (platform) #查看platform支持的功能:d IR (p Latform) in [4]: Exit ()

Simple Method :

1. Compile and install the new version to a specific path :

2.pyenv

source package installation python:

[[Email protected] ~]# ll python-2.7.6.tgz -rw-r--r--.  1 root root  14725931 1 Month   25 2015 python-2.7.6.tgz[[email protected] ~]# tar  XVF PYTHON-2.7.6.TGZ relies on Readlinde-devel development program [[email protected] ~]# yum -y  Install readline-devel[[email protected] ~]# cd python-2.7.6[[email protected]  Python-2.7.6]# lsconfig.guess  configure.ac  Grammar      Lib      Makefile.pre.in  Objects  PCbuild         readme    toolsconfig.sub    demo           Include     LICENSE   Misc             Parser    pyconfig.h.in &nbSp riscosconfigure     doc            install-sh  Mac      Modules           PC       Python          setup.py[[email protected] python-2.7.6]# ./configure --prefix=/usr/ Local/python-27checking build system type... x86_64-unknown-linux-gnuchecking host  system type... x86_64-unknown-linux-gnuchecking for --enable-universalsdk...  Nochecking for --with-universal-archs... 32-bitchecking machdep... linux2checking  EXTRAPLATDIR... checking for --without-gcc... nochecking for gcc...  NOCHECKING FOR CC ...  nochecking for cl.exe... noconfigure: error: in  '/root/python-2.7.6':configure: error: no acceptable c compiler found in  $PATHSee   ' Config.log '  for more details need to be installed  gcc[[email protected] python-2.7.6]# yum  -y install gcc[[email protected] python-2.7.6]# ./configure --prefix=/usr/ local/python-27[[email protected] python-2.7.6]# make && make  Installtab complement function: (for Ipython function module [[email protected] ~]# wget [[email protected] ~]#  tar xf ipython-1.2.1.tar.gz [[email protected] ~]# cd ipython-1.2.1[[ email protected] ipython-1.2.1]# /usr/local/python-27/bin/python2.7 setup.py build[[ email protected] ipython-1.2.1]# /usr/local/python-27/bin/python2.7 setup.py install[ [EMAIL PROTECTED] IPYTHON-1.2.1]# LN -SV /USR/LOCAL/PYTHON-27/BIN/PYTHON2.7 /USR /bin/python2.7 "/usr/bin/python2.7 " -> "/usr/local/python-27/bin/python2.7 "       [[email  protected] ipython-1.2.1]# ln -sv /usr/local/python-27/bin/ipython /usr/bin/ Ipython "/usr/bin/ipython"  ->  "/usr/local/python-27/bin/ipython"

Data

A collection of data elements that are organized in a way , such as numbering elements , that can be numbers or characters, or even Other data Structures   

Python The most basic data structure is the sequence

each element in the sequence is assigned an ordinal -- , also becomes index : index from 0 start numbering

Python include 6 types of built-in data series : list, tuple, number string

Unicode string , Buffer objects, and xrange Object

Python key elements of

1. basic data Types

2. Object references

3. combining data types

4. logical Operators

5. Control flow Statements

6. arithmetic operators

7. input / output

8. creation and invocation of functions

1. basic data Types

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/02/wKioL1TE6K-Q4c0WAAGsYZgS4EU727.jpg "title=" 1.PNG " alt= "Wkiol1te6k-q4c0waagsyzgs4eu727.jpg"/>

Variable assignment:

Number: in [8]: num=1in [9]: ID (num) out[9]: 32365672In [ten]: num=2in [all]: ID (num) out[11]: 32365648 letter: In []: Name= "Jerry" in [ []: Print Name[0]jin []: Print Name[1]ein [+]: print Name[2]rin [+]: ID (name) out[16]: 43542256 view Variable type: in [+]: type (nu m) out[17]: Intin [+]: type (name) out[18]: str# View platform Supported features: DIR (Platform) in [3]: Dir (platform)

2. Object references

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/05/wKiom1TE6FWRk1AZAAKWsWiVGWc954.jpg "title=" 2.PNG " alt= "Wkiom1te6fwrk1azaakwswivgwc954.jpg"/>

Variable rules

* can contain only letters , Digital , and underline, and cannot start with a number

* distinguish Letter case

* prohibit use of reserved words

Python2 and the Python3 the reserved words are different

Naming conventions

* A variable name that begins with a single underscore ( _x ) will not be From module import* Statement Import

* variable name with underscore before and after (_x_) is a system-defined variable name , the Python The interpreter has a special meaning.

* A variable name that starts with two underscores but does not end with an underscore (__x) is a local variable of the class

* in interactive mode, the variable name "_" results for saving the last expression

In [1]: 1+1out[1]: 2In [2]: Print _2


Note : the variable name has no type and the object has



This article is from the "Linux Revolution" blog, so be sure to keep this source http://kaibinyuan.blog.51cto.com/7304008/1608150

Python Learning Notes (ii) Python syntax _1

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.