The best IDE for Python: a summary of Pycharm tips

The best IDE for Python: a summary of Pycharm tips

1. Settings of pycharm

Generally, the first time we use pycharm, we will make some settings, which can be adjusted according to personal needs. Here are some explanations on my own settings:

Enter the settings from the setting under file, as shown in the following figure:

Then we enter the setting interface, first we can set the interface style and toolbar font size, as shown by the red line

Next, we will generally set the font style when writing the code, choose the appropriate font, size and interval, which is conducive to the comfort of writing the program, and it will be easy to write. . .

Next we need to specify our encoding form, which is conducive to our code compilation and writing

After all, the utf-8 codec mode conforms to the Chinese coding habits, and then we hope that every time we write code, we can write some information about this file in the header of the file, such as time, compiler, etc., so that we can write A writing

template, so that every time a new file is created, this information will be automatically added to the header of the file. Here we take the py file as an example. You can write it in this mode

For the sake of convenience, I will just type them out and copy them directly!

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: albert time:${DATE}

The next step is the highlight, we need to specify the compiler, this is the soul operation,

Since my python is installed with anaconda, it is enough to directly specify the python path under anaconda here. If you want to load other compilers, you can click show all below, and then load it in.

2. Pycharm use and shortcut keys

In pycharm, you can load third-party libraries used by python. Just after specifying the compiler, click the plus sign on the right and enter the search box to find the third-party library you want to load, but this method is too slow. The terminal uses pip combined with mirroring to install, so I won't elaborate on it here.

As for the shortcut keys, there may be slight differences between different versions, some of which are commonly used:

  • Note: After selecting Ctrl +/
  • Positioning: Ctrl + left mouse button
  • Indentation: Tab/Tab+shift
  • Line break: shift + enter
  • Compile: Ctrl+shift+F10
  • View path: ctrl+l (or enter pwd in the terminal)

I can’t remember the others, you can check it in the settings

3. Some problems encountered in the use of pycharm

(1) Sometimes when we write code, we will find some tildes (non-coding errors) appear under the code. The quick solution is to click on the lower right corner of the interface to reduce the highlighting level to syntax errors.

The root cause is to remove the detection options in pycharm in the settings, but it is not recommended. I use the former.

(2) Unable to compile when running the code

Generally, if we want to run the code, we can run the current file with the right mouse button, but sometimes the following situation occurs

All we need to do is to change the name of the py file.

pycharm set background image

*Disclaimer: This article is organized on the Internet, and the copyright belongs to the original author. If the source information is wrong or infringes on rights, please contact me

Reference: The best IDE for Python: a summary of Pycharm tips-Cloud + Community-Tencent Cloud