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
- Project: Current project name >project Interpreter>add Local
- Create python files, Python modules under Pycharm
- File>new>python File
- File>new>python Package
- Installing Python third-party modules using Pycharm
- 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.
- Do not use tab, tab=4 space: Editor>code Style>python
- Font, Font color: Edit>colors & Fonts>python
- Turn off Automatic Updates: Appearance & Behavior>system settings>updates
- Script Header settings: Edit>file and Code Templates>python script Note: other similar
- Display line number: Edit>general>appearance>show line numbers Note: 2016.2 lines are displayed by default
- The right vertical bar is the code specification for PEP8, prompting a line not to exceed 120 characters
- 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.
- Query and configuration of common shortcut keys: Keymap
- Ctrl + D: copying when moving forward
- Ctrl + E: delete When moving forward
- SHIFT + Enter: Quick Line Wrapping
- Ctrl +/: Quick comment (Batch comment after multiple lines are selected)
- Tab: Indent the current line (bulk indent after multiple rows are selected)
- Shift + Tab: Cancel indent (you can cancel the indent in batches after multiple lines are selected)
- Ctrl + F: Find
- Ctrl + H: replace
- Pycharm Install plug-ins, such as markdown support, database supporting plugins, and more.
- Plugins>browse repositories (below three buttons in the middle) > Search ' markdown support ' >install
- 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?
- You need to install git locally.
- Version Control>git
- 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.
- Copy file path: Left file list Right-click File >copy path
- Open in File Manager: Right-click Selected Files > Find show in Explorer
- Quick positioning: Ctrl + some built-in modules, click to expand in the source file
- View structure: IDE left sidebar structure View the structure of the current project
- tab Bulk Exchange Space:edit>convert indents
- Todo use: # Todo to record things
- Debug set breakpoints, directly click the line number and the space between the code to set breakpoints (the video forgot to say)
- 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
- File Right-click >local history to see the comparison before and after the file modification
- 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
- IDE Right sidebar >database
- How to get rid of annoying wavy lines? What is PEP8 again?
- Comment on a single line: #+1 space + Comment content
- Code followed by comment: 2 space +#+1 space + comment content
- SSH Terminal:default Encoding:utf-8
- 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