The first day python environment variable installation (2.7)

First, what is python

Python is a combination of interpretive compiler, interactive object-oriented scripting language and high-level.

Python's design is simple, easy to learn, free, open source, object-oriented, scalability

  • Python is an interpreted language:  This means that the development process does not compile this link. Like PHP and Perl languages.

  • Python is an interactive language:  This means that you can in a Python prompt  execute code directly after >>>.

  • Python is an object-oriented language:  This means that Python supports object-oriented style of programming or code encapsulated in objects.

  • Python is a beginner's language: Python for junior programmers, is a great language, it supports a wide range of application development, from simple word processing to the WWW browser and then to the game.

Two, python environment variable installation

window environment:

Open WEB browser to access https://www.python.org/downloads/windows/

Add Python directory environment variable:

At the command prompt box (cmd): Input

path=%path%;C:\Python 

Press "Enter".

Note:  C: \ Python is Python installation directory.

You can also set the following ways:

  • Right-click on "Computer" and then click "Properties"
  • Then click on the "Advanced System Settings"
  • Select "System Variables" window under the "Path", double click!
  • Then in the "Path" line, add the path to the python installation (my D: \ Python32), so in the back, add the path. ps: Remember, the direct path with a semicolon ";" to separate!
  • After the last set successfully, the cmd command line, enter the command "python", can have associated display.

note: 

For the novice to learn Python, the Anaconda installation package management software is a good choice, you can reduce a lot of trouble subsequent installation of various Python package. Write code in Anaconda own notebook than IDE and Terminal experience much better.

mac installation environment:

MAC systems are generally comes with Python2.x version environment, you can also link  https://www.python.org/downloads/mac-osx/  download the latest version installed on

Third, the simple code practice

#!/usr/bin/python

print("Hello, World!")

Fourth, the Chinese encoding

Python in the default encoding format is an ASCII format and can not print correctly when characters did not modify the encoding format, so when reading Chinese error.

Solution to simply add at the beginning of the file  # - * - coding: UTF- 8 - * - or the  # coding = utf-8 on the line

E.g:

! # / usr / bin / Python 
# - * - Coding: UTF-8 - * -
Print ( "Wuhan, come on!")

 Fives,

Guess you like

Origin www.cnblogs.com/zi-yangguang/p/12272996.html