Pycharm usage tips and pycharm usage tips

Source: Internet
Author: User

Pycharm usage tips (reprinted) and pycharm usage tips
Pycharm usage tips (reprinted)

 

Reprinted from: http://www.cnblogs.com/cloudtj/articles/5980666.html

 


0. Install the python interpreter first.
Linux does not need to be installed. It is provided by default and needs to be installed in Windows. The latest versions are 2.7 and 3.6.
: Https://www.python.org/downloads/windows/

 

Default installation path: C: \ Python27 \

Remember to check the environment variable

Bytes --------------------------------------------------------------------------------------------------------

1. Configure the Python interpreter for your Python project under Pycharm

View-> Toolbar and Tool Buttons


Project: Current Project Name> Project Interpreter> add Local

Or

File-> setting

 

Project: pyproject1-"Project Interpreter

If python 3.6 and 2.7 are installed on the current computer, if the project is written in 3.6, You must select 3.6 As the parser.

 

 

Bytes ----------------------------------------------------------------------------------------------------
2. Create a Python file and a Python module in Pycharm.
File> New> Python File
File> New> Python Package

Bytes -----------------------------------------------------------------------------------------------
3. Use Pycharm to install Python third-party modules
Project: Current Project Name> Project Interpreter> click the green plus sign on the right

PyPI-the Python Package Index -- python Package Index
Pip install

Third-party module installation path: C: \ Python27 \ Lib \ site-packages

Linux:

/Usr/lib/python2.6/site-packages
/Usr/lib64/python2.6/site-packages/

 

Search for and install third-party modules

Select the module version

Repository source, actually connected to: https://pypi.python.org/simple/

Download from the Internet, the computer must be able to access the Internet

Installation path: C: \ Python27 \ Lib \ site-packages

Bytes ---------------------------------------------------------------------------------------------------

4. Pycharm Basic settings, such as no tab, tab = 4 spaces, Font, font color, subject, script header settings, and line number display. How to export and import custom settings.

Do not use tab or tab = 4 spaces: Editor-> Code Style-> Python
There are four spaces for indentation. No matter which operating system you are in, the IDE will not be faulty. The tab may be indented in other operating systems.

Use tab character and smart tabs are removed, and the following are 4, 4, 8


Font and font color:

Appearance & Behavior-> Appearance-> Theme: Darcula

Editor-> Colors & Fonts-> Font
Primary font: Courier New, Size: 14

 

 

Disable Automatic update: Appearance & Behavior-> System Settings-> Updates


Script header settings: Editor-> File and Code Templates-> Python Script Note: other similar

 

 

Display line number: Editor-> General-> Appearance-> Show line numbers Note: 2016.2 the default line number is displayed.


The vertical line on the right is the code specification of PEP8, prompting a line of no more than 120 characters


Export and Import your custom configuration: File-> Export Settings, Import Settings

 

 

 

Bytes -------------------------------------------------------------------------------------------------------------
5. Common shortcut keys, such as copying the current row, deleting the current row, comments in batches, indentation, search, and replacement.
Common shortcut key query and configuration: Keymap
Ctrl + D: copy the current row
Ctrl + E: Delete the current row
Shift + Enter: fast line feed
Ctrl +/: quick comment (you can comment multiple lines in batches)
Tab: indent the current row (multiple lines can be selected and batch indented)
Shift + Tab: unindent (you can unindent multiple lines in batches)
Ctrl + F: Search
Ctrl + H: replace

 

Bytes --------------------------------------------------------------------------------------------------------------------
6. Install Pycharm plug-ins, such as Markdown support and database support plug-ins.
Plugins> Browse repositories (the one in the middle of the three buttons below)> Search for 'markdown support'> install
Three options are available for the View in the upper right corner. Generally, you can write them on the left in the middle and preview them in real time on the right.

 

Bytes -----------------------------------------------------------------------------------------------------
7. Git Configuration
Install Git locally
Version Control> Git
After you have configured a version control system such as Git, you can easily view unnecessary files in diff.

 

Bytes -----------------------------------------------------------------------------------------------------------------

8. Common Operation guide. For example, copy the file path, open it in the file manager, quickly locate it, view the module structure view, change the space in batches by tab, use TODO, and use Debug.
Copy file Path: Right-click the file list on the left and select the File> Copy Path
In the file manager, right-click the selected file and choose Show In Explorer.
Quick positioning: Ctrl + some built-in modules, click to expand in the source file
View Structure: view the Structure of the current project in the left sidebar of IDE
Tab for space in batches: Edit> Convert Indents
TODO usage: # What TODO wants to record
Debug sets the breakpoint, and click the blank space between the line number and the code to set the breakpoint (I forgot to say it in the video)
Right-click on the Tab page> Move Right (Down) to Move the current Tab page to the Right (bottom) of the window for convenient comparison
Right-click the file> Local History to view the comparison before and after file modification.
You can see some useful information in the lower right corner of the IDE. The cursor is currently in the nth line of the character, the current carriage return line breaks, the current encoding type, the current Git Branch
Right sidebar of IDE> Database

 

Bytes --------------------------------------------------------------------------------------
9. Remove annoying wavy lines
Comment on a single line: # + 1 space + comment content
Comments followed by the Code: 2 spaces + # + 1 spaces + Comments
Maintaining a good unified programming style is very important.
Google has many programming guidelines for various languages, and Python has its own programming specifications,
PyCharm also checks the code in the editor according to certain specifications (such as PEP8.
The programming style here includes the code writing format and the code logic organization layer.
Https://github.com/iwhgao/zh-google-styleguide/blob/master/google-python-styleguide/python_language_rules.rst
Https://github.com/iwhgao/zh-google-styleguide/blob/master/google-python-styleguide/python_style_rules.rst

 

 

Bytes ----------------------------------------------------------------------------------------
10. SSH Terminal: Default encoding: UTF8
Settings> Tools> SSH Terminal> Default encoding in the last line: Select UTF ### 8

 

 

 

 

Example

#! /Usr/bin/env python #-*-coding: UTF-8-*-# __author _ = "huazai" pycharm user guide Date: 2016.08.12 "def test (num)" test function "for I in range (num ): # comment j = I + 1 if j % 2 = 0 print j # comment else in a separate line: print "The end" if _ name __= = "_ main _": test (10)

 

 

 

 

F

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.