Learn the path to PYTHON, Day 1-python Foundation 1

Source: Internet
Author: User
Tags windows x86 version control system

A PYTHON installation

1. Python download

(1) www.python.org official website

(2) Select the executable file (64-bit 3.5.2Windows x86-64 executable installer or 32-bit 3.5.2 Windows x86 executable installer), (64-bit 2.7.12 Windows x86-64 MSI Installer or 32-bit 2.7.12 Windows x86 MSI installer)

2. Python installation, including Python2 and Python3. How to configure a two-version environment locally. What to do with the Python version of the production environment that extends to work.

(1) The recommended installation path is C:\Python27 and C:\Python35, because if the path has spaces (C:\Program files\python35) pip may be problematic.

(2) For example: Change C:\Python35\python.exe to Python3.exe,c:\python35\scripts\pip.exe to Pip3.exe, if there is already pip3.exe, delete the Pip.exe.

(3) Later need to use PYTHON3 environment in the terminal input Python3 on the line (input python is python2.7 environment), the same PIP3 is the use of Python3 pip

(4) The PIP may be faulty after the above changes (the terminal input >PIP3 error is as follows: Fatal error in the launcher:unable to create process using ' "), need to upgrade the corresponding PIP3 (terminal input > python3-m pip install-u Pip)

(5) A description of PIP, similar to Yum. Previous versions of Python may also have a separate pip, and Python now comes with Pip, without having to install the PIP separately.

(6) Setting of environment variables

computer (My Computer \ This computer) > right-click > Properties > Advanced system Settings > Environment variables > System Variables

Two Pycharm basic use
  • Configure the Python interpreter for your Python project under Pycharm
    1. Project: Current project name >project Interpreter>add Local
  • Create python files, Python modules under Pycharm
    1. File>new>python File
    2. File>new>python Package
  • Installing Python third-party modules using Pycharm
    1. Project: Current project name >project interpreter> Click on the right green small plus sign
  • Pycharm basic settings, such as not using tab, tab=4 spaces, fonts, font colors, themes, script header settings, display line numbers, and so on. How to export and import custom settings.
    1. Do not use tab, tab=4 space: Editor>code Style>python
    2. Font, Font color: Edit>colors & Fonts>python
    3. Turn off Automatic Updates: Appearance & Behavior>system settings>updates
    4. Script Header settings: Edit>file and Code Templates>python script Note: other similar
    5. Display line number: Edit>general>appearance>show line numbers Note: 2016.2 lines are displayed by default
    6. The right vertical bar is the code specification for PEP8, prompting a line not to exceed 120 characters
    7. Export and import your custom configuration: File>export Settings, Imports Settings
  • Common shortcut keys, such as copying the current line, deleting the current line, bulk commenting, indenting, finding, and replacing.
    1. Query and configuration of common shortcut keys: Keymap
      1. Ctrl + D: copying when moving forward
      2. Ctrl + E: delete When moving forward
      3. SHIFT + Enter: Quick Line Wrapping
      4. Ctrl +/: Quick comment (Batch comment after multiple lines are selected)
      5. Tab: Indent the current line (bulk indent after multiple rows are selected)
      6. Shift + Tab: Cancel indent (you can cancel the indent in batches after multiple lines are selected)
      7. Ctrl + F: Find
      8. Ctrl + H: replace
  • Pycharm Install plug-ins, such as markdown support, database supporting plugins, and more.
    1. Plugins>browse repositories (below three buttons in the middle) > Search ' markdown support ' >install
    2. Top right corner view has three options, generally we use the middle of the left side of the writing, the right real-time preview
  • Git configuration?
    1. You need to install git locally.
    2. Version Control>git
    3. After configuring the version control system such as Git, it is easy to diff to see the file without
  • Common Operations Guide. For example, copy file paths, open in File Manager, quickly locate, view module structure view, tab bulk space, TODO usage, debug use.
    1. Copy file path: Left file list Right-click File >copy path
    2. Open in File Manager: Right-click Selected Files > Find show in Explorer
    3. Quick positioning: Ctrl + some built-in modules, click to expand in the source file
    4. View structure: IDE left sidebar structure View the structure of the current project
    5. tab Bulk Exchange Space:edit>convert indents
    6. Todo use: # Todo to record things
    7. Debug set breakpoints, directly click the line number and the space between the code to set breakpoints (the video forgot to say)
    8. Right-click on the tab page and move the current tab to the right (bottom) of the window to make the >move easier to compare
    9. File Right-click >local history to see the comparison before and after the file modification
    10. The IDE can see some useful information in the lower right corner, the cursor is currently in the first few lines of characters, the current carriage return line, the current encoding type, the current Git branch
    11. IDE Right sidebar >database
  • How to get rid of annoying wavy lines? What is PEP8 again?
    1. Comment on a single line: #+1 space + Comment content
    2. Code followed by comment: 2 space +#+1 space + comment content
  • SSH Terminal:default Encoding:utf-8
    1. Settings>tools>ssh terminal> last line default encoding: Select UTF-8
Three user input

In Python 2:

1 name = Raw_input ("Please insert your name:")2print Name

In Python 3:

1 name = input ("Please insert your name:")2print name
Four use for, if...else write about guessing numbers game
1Number = 202  forIinchRange (10):3Guess = input (" in number")4     ifNumber = =guess:5         Print("You got it")6          Break7     elifNumber >guess:8         Print("It ' s too small")9     Else:Ten         Print("It ' s too big")

Break (end the entire cycle); pass (placeholder); Continue (end single cycle)

Learn the path to PYTHON, Day 1-python Foundation 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.