A preliminary understanding of Python

Source: Internet
Author: User
Tags delete key python script

  Starting today, I'm going to keep writing a blog every week, a review of my week's learning summary and knowledge. This can deepen the understanding of learning and understanding, small language or something is not good, but I do not write novels and poetry or anything, so sometimes the wording is not good, but also please a lot of tolerance and understanding, 3Q!!!

I was also accidentally exposed to the language of Python, although I was a computer-learning background, but it was really interesting for python at the end of 2016. I began to start with my curiosity about Python, I read the preliminary introduction of Python only to know that I and Python still have some fate.

The founder of Python is Guido van Rossum (later everyone called Uncle Tortoise). Because of the early hardware device problems--the capacity of the memory limit, causing the programmer to think like a computer, so that every inch of the computer is fully applied, although the effort to optimize, or the computer will be paralyzed and other problems appear, even good C will appear this problem. At this time, Uncle Turtle think with C such a language is too wasteful, so he switched to the shell, however, Shell is called command can not fully invoke the computer to use energy.

Uncle Turtle himself wanted to be able to have a language as well as c as a full call to the function of the computer interface, and the shell as easy as programming. ABC language gave the turtle Uncle Dawn, but ABC still has shortcomings, is the difficulty of input and output can not solve is fatal.

In 1989, in order to pass the Christmas holiday, Uncle Turtle began to write the Python language compiler. The name is from Uncle Turtle's beloved TV drama--monty Python s Flying Circus. 1991, the first Python compiler was born.

So what I said before about the fate of Python is: I was 1989 born, and Python's icon is the big snake, then I also belong to snakes. In any case, the same year was born, the same zodiac. That's the fate!

As for the installation of Python I will no longer here too detailed to say, want to know more to find degrees Niang Ah!

Windows installation is simple:

is to go to the official website https://www.python.org/, download-and-install.

Linux Installation: 

  First go to the Python official website download Python3 source package, Website: https://www.python.org/

Release files:

  Tar-xvzf python-3.5.1.tgz

Enter directory:

  CD PYTHON-3.5.1/

To configure the installation directory, the other options are generally default:

  ./configure--prefix=/usr/python

Next compile the source code:

  Make

To perform the installation:

  Make install

The entire process is approximately 5-10 minutes, and after the installation is successful, the installation directory is/usr/python

The original python in the system is in/usr/bin/python, ls-l can see that Python is a soft link to the python2.7 in this directory

We can not delete this, do not make any changes to the original default environment, only create a new Python3 soft link, just need to execute Python3 code when python to change to Python3, or Python script header interpreter to #!/usr/bin/ Python3

Here is a soft link to create the following:

  $ ln-s/usr/python/bin/python3/usr/bin/python3

This is established, and then directly execute the PYTHON3 command can be called Python3, in addition, if you look carefully at the Python installation directory of the bin directory, actually Python3 is also a soft link, Link to python3.5.1, so many links are also for multiple versions of the management more convenient,

Python3 new version of the installation is these, in addition, you may encounter a problem is that the Python3 interactive interface is particularly difficult to use, delete can not be used normally, you must press CTRL + DELETE key to be able to, up and down key Repeat command can not be used, adjust the cursor can not be used, so debugging code efficiency is very low, The reason is Python3 missing readline This dependency, the default use of PIP3 install ReadLine will be prompted to find the package, so can only be manually installed

Because ReadLine relies on the ncurses library, if there is no such library, compile ReadLine will prompt can not find-lncurses, if in the CentOS environment can execute the following command installation:

  Yum-y Install ncurses Ncurses-devel

After installing the ncurses library, then install Readline,readline can be downloaded in PyPI, address: https://pypi.python.org/pypi/readline, here must download the source package, the rest can only be used for Python2, After downloading, perform the following command installation:

  TAR-XVZF readline-6.2.4.1.tar.gz  cd readline-6.2.4.1/  python3 setup.py Install

This completes the Python3 installation of the ReadLine, and then into the interactive interface all the operations are working

  

A preliminary understanding of Python

Related Article

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.