Pycharm is one of the most commonly used ides for Python development. It is highly compatible and has a variety of features, such as debugging, syntax highlighting, smart tips, etc. It also supports web development frameworks such as Django, which is very efficient once you get used to it.

Pycharm is also a double-edged sword for those who are beginning to learn Pycharm. Some of you may feel confused when you see a lot of English interfaces when you first start using Pycharm. Pycharm, the most popular IDE in Python development, helps you keep up with the speed of older drivers!


First, commonly used small skills

1. Set the code font.

Click “File” in the upper left corner, select “Settings”, type “font” to find the “font”, and set the number in the “Size”. The default is 12, 18 or 20 is recommended.


2. Set the text size on the menu page

This is a bit different from the above, which resize the code text, but does not change the text size of the menu interface, if your menu interface text is small, such as this:

Then you need to adjust the text size of the menu interface. Click “File” in the upper left corner, select “Settings”, type “font”, go to “Appearance”, check “Use Custom Font”, You can choose the font Size you like in the following Size.


3. Quick multi-line comment or uncomment

Although we can use “#” to comment a single line of code, if there are multiple lines of code to comment, then it is a bit troublesome to type “#” line by line. Here we can use the mouse to select multiple lines of code, and then press Ctrl+/ to comment multiple lines of code, and also can uncomment multiple lines of code.


4. Code formatting and code specification

When we started to write code, it was inevitable that the code was not written properly. Although it did not affect the operation, the readability was low, especially when you read a long and non-standard code, you would feel the pain.

For example, this kind of non-standard writing, the middle from time to time to give you a few Spaces.

This problem is actually very easy to solve, as long as we finish writing the Code, find the menu bar “Code”, click “Reformat Code” can automatically standardize the Code processing.


5. Quickly modify the same variable or class

When we write code, we often have to define a lot of variables or classes. Variables or classes may be used in more than one place when we write code. If we need to change all of the variables or classes in the code, should we change them one by one?

Of course not. Simply select the variable or class you want to Rename, right-click on Refactor from the pop-up options, and click Rename to make global changes.

For example, if I wanted to change all the “n” variables in the code to “I”, the operation would be as follows:


6. Quickly find variables, functions, etc

When our code is long, it is difficult to swipe through to find a variable or function, so we need to use the shortcut Ctrl+ F for quick lookup.

For example, if I want to find out where the “runGame” function is used in the Snake project, I can simply use Ctrl+ F to bring up the small window and type in the keyword “runGame” to find all the places where “runGame” appears in the code.


7. Search for the modification history

Sometimes it takes several days to complete the project. But what if we open PyCharm today to add a new function, and after a long time, we don’t want it anymore. We want to get back yesterday’s version, but it has been a long time, and we can’t undo it?

This is when you need to search for your History. Pycharm is very human and keeps a History of every change you make. Just right click on the file and you can find all the historical versions in Local History.

Take the simplest example, let’s say I have a function in my current code that says’ execute finished ‘. I don’t need it, but I can’t undo it now. What should I do? At this point, we can go to Local History to find the historical version and change the current version back to the historical version. (Except for direct deletion, which is not our goal)


8. Install and configure pippy domestic source

When we used PIP to install some resources, PyCharm was used to download foreign resources by default. Sometimes the installation failed due to network problems. In fact, we can configure it to download domestic resources to solve the problem.

The most common one is to download it from the open source mirror site of Tsinghua University. We only need to set this in PyCharm, and then it will be downloaded in China by itself.

Setup method: Click “File” → Click “Settings” → find “Python Interpreter” under Project → Click “+” → Click “Manage Repositories” → Click “+” → Enter the address of Tsinghua University open Source Software Repository: pypi.tuna.tsinghua.edu.cn/simple


9. The installation package

We often need to install packages when writing code to do something, so installing the package for PyCharm is a must.

Methods:

Click “File” in the top left corner → Click “Settings” → find “Python Interpreter” under Project → click “+” → Enter the name of the Package you want to Install, such as “PyGame” and click “Install Package” below to start the installation. Once installed, it’s ready to use.

Note that it can only be used after the installation is complete. There will be a progress bar at the bottom of the interface:


10. Debugging

When writing code, it is easy to report errors, but sometimes it is hard to see the problem on the surface. Then we need to debug, which is a common technique in the development process.

How to debug? Click to the left of the line of code where you think something might go wrong and a red dot appears. This is called a breakpoint. After setting the breakpoint, we right click “Debug project name” to run, and then go to the run interface, we step by step, and can see the value of some variables inside the change situation.

Debugging also has more doorways, specific debugging skills we can go to the Internet search, I will not explain too much here.


11. Personality Setting?

This is an additional function. You can set the background of your PyCharm according to your personal needs. After all, it is tiring to read English and numbers when writing code, but you can also watch something else occasionally, like your girlfriend.

Setting method:

① Open PyCharm, click File, and select Settings.

② Under Appearance & Behavior, click on Appearance and Background Image.

③ There is “… “in the upper right corner. “, you can choose the picture you want to use as the background, after confirming, choose the way you like to display, I think the second one is still good.

Finally, set the brightness of the background image. I recommend a brighter background at 10% opacity, too bright will affect the code, personal preference and image color.

(For the record, that background is not mine.)


Two, common shortcut keys

Finally, I’m going to give you a list of Pycharm shortcuts that you’re going to use to write your code.

Recently too much stealing map stealing text, can only add watermark, no watermark can be private chat me, or you go to sort out some of their own commonly used is also ok.


conclusion

Me here advise those English is not good, afraid of English software friends, don’t be so to the development of the Chinese version of the software, in addition to the stability of the Chinese has no native English will be better, there is a big reason is that now the mainstream of development software mostly in English original edition, if you are a permanent Chinese version, When you come across English software, you will be at a loss.

Just like when we learn to drive, if you learn automatic transmission, then one day to give you a manual transmission, you can not drive, but if you learn manual transmission, then to open automatic transmission that is easy.

The Chinese version is like automatic gear, the Original English version is like manual gear, do not begin to understand English on the light. I’m not sampling kitsch, I’m just publishing, the original version is better, of course, there are exceptions to everything, if you are learning easy language, then the Chinese version is undoubtedly the best.