Retired uncle long 2021-08-09 02:27:45 阅读数:496
Pycharm As Python Develop the most commonly used IDE One of , Not only is it compatible , And the functions are quite rich , Such as debugging 、 Syntax highlighting 、 Intelligent prompt and other functions , It also supports web Development framework, such as Django etc. , When you get familiar with it , The development efficiency is quite high .
But for beginners ,Pycharm It is also a double-edged sword with rich functions , Some friends will be confused when they see a lot of English interfaces just after they get started , Ha ha ha , It doesn't matter. , Let's teach you today 11 individual Pycharm The most common technique , As well as some pycharm Common shortcut keys , Let's get you started quickly Python Most commonly used in development IDE Pycharm, Keep up with the old driver's speed !
Click on the top left “File”( file ), choice “Settings”( Set up ), Input “font”( typeface ) find “Font”, stay “Size”( size ) Set the number inside , The default is 12, Suggest 18 perhaps 20 That's all right. .
There are some differences between here and above , The above is to resize the code text , But it doesn't change the text size of the menu interface , If your menu interface text is small , Like this :
Then you need to adjust the text size of the menu interface , Click on the top left “File”, choice “Settings”, Input “font”, find “Appearance”, stay “Use custom font” After checking the front , It can be in the back Size Choose the font size you like .
Although we can use... In writing code “#” To make a single line comment , But if there are multiple lines of code that need comments , Then knock... Line by line “#” It's a little bit of a problem , Here we can select multiple lines of code with the mouse , Then press Ctrl+/ You can annotate multiple lines of code , You can also uncomment multiple lines of code .
When we first started writing code , It is inevitable that the code is not standardized , Although it does not affect the operation , But the readability is low , Especially when you read a long and nonstandard code , You will feel the pain .
For example, this non-standard writing , Give you a few spaces from time to time .
This problem is actually very easy to solve , We just have to write the code , Find the menu bar “Code”, Click on it. “Reformat Code” Can automatically standardize the code .
When writing code, we often have to define many variables or classes , Variables or classes may be used in multiple places when writing code , If we need to modify a variable or class in the code , So are we going to modify it one by one ?
Of course not , We just need to select the variable or class that needs to be renamed , Right click the pop-up option and select Refactor, And then click Rename, You can make global modifications .
For example, I want to put all the "n" The variables are changed to “i”, Then the operation is as follows :
When our code is long , If you slide from beginning to end to find a variable or function, it is very troublesome , At this time, we need to use the shortcut key Ctrl+f For quick search .
For example, I want to find out in the snake project “runGame” Where is this function used , So we just need to use Ctrl+f Call up small window , Then type the keyword “runGame” You can find it in the code “runGame” All locations that appear .
When writing a project, you often have to modify it , Sometimes it takes several days to complete , But if we open it today pycharm To add a new feature , After doing it for a long time, I don't want it anymore , Want to get back yesterday's version , But for a long time , There's no way to undo it , What should I do ?
At this time, you need to find the modification history ,pycharm It's still very human , Every step you make changes , It helps you keep a historical record , Just right click on the file , stay Local History You can find all the historical versions in it .
Take the simplest example , For example, I now have a function in my code to do “ Prompt after execution ’ end of execution ’”, I don't need it , But I can't undo it now , What should I do ? This time we can go to Local History Find historical versions , Change the existing version back to the historical version .( In addition to directly deleting , Direct deletion is not our purpose )
We were using the pip When installing some resources ,pycharm The default is for us to download foreign resources , Sometimes the installation fails due to network problems , In fact, we can configure , Let it download domestic resources .
The most common is to go to the open source mirror station of Tsinghua University to download , We just need to pycharm Set it up , In the future, it will download it in China by itself .
Setup method : Click on the top right corner “File”→ Click on “Settings”→ find Project Below “Python interpreter”→ Click on “+”→ Click on “Manage Repositories”→ Click on “+”→ Enter the address of the open source software mirror station of Tsinghua University :https://pypi.tuna.tsinghua.edu.cn/simple
When writing code to realize some functions, we often need to install software packages , So here it is pycharm The function of installation package must be mastered .
Method :
Click on the top left corner “File”→ Click on “Settings”→ find Project Below “Python interpreter”→ Click on “+”→ Enter the name of the package you want to install , for example “pygame”, Then click below “Install Package” It's time to install , After installation, you can use .
One thing to note is that it can only be used after installation , There will be a download progress bar at the bottom of the interface :
When writing code, we can easily report errors , But sometimes it's hard for us to see the problem in the open , Then we need to debug at this time , This is also a common skill in the development process .
How to debug ? Click on the left of the line of code that you think may go wrong and a red dot will appear , We call it a breakpoint , As long as the program runs to the breakpoint, it will automatically stop . After setting the breakpoint , Let's right-click and choose “Debug Project name ” To run , Then to the operation interface , Let's go step by step , At the same time, we can see the changes of the values of some variables .
There are many ways to debug , For specific debugging skills, you can search on the Internet , I won't explain too much here .
This is an additional function , You can give it to yourself pycharm Set the background of personality , Look at personal needs , What you want to set can be set , After all, it's tiring to read English and numbers when writing code , It's OK to see something else occasionally , Like your girlfriend .
Setup method :
① open pycharm, Click on File, choice settings.
② stay Appearance & Behavior Under the option, click Appearance, Click on Background Image.
③ There's... In the upper right corner “…” Click on the right place , You can choose the picture you want as the background , After determining , Choose the way you like to show , I think the second one is good .
Finally, set the brightness of the background picture , I suggest a brighter background in 10% Transparency is about the same , It's too bright to look at the code , Look at your preferences and picture colors .
( Explain , That background is not mine )
Last , I'd like to attach Pycharm Summary of commonly used shortcut keys , I wish you more and more smoothly in the process of writing code .
There are too many pictures and articles stolen recently , You can only add watermark , No watermark can talk about me in private , Or you can sort out some commonly used ones by yourself .
I'm here to advise those who are not good at English 、 Friends who are afraid of English software , Don't install the Chinese version of development software , Except for the Chinese version, the stability of the original English version will be better , Another big reason is , Now most of the mainstream development software is in the original English version , If you permanently the Chinese version , One day, you need to use the English version of the software , There's nothing you can do .
Just like when we learned to drive , If you learn automatic transmission , So one day I'll give you a manual transmission , You can't drive , But if you learn to shift manually , Then it's easy to turn on Automatic .
The Chinese version is like automatic , The original English version is like a manual gear , Don't be afraid of taking things lightly because you don't understand English at first . I'm not a foreigner , I'm just Publishing , The original version will be better , Yes, of course , There are exceptions to everything , If you study easy language , So the Chinese version is undoubtedly the best .
版权声明:本文为[Retired uncle long]所创,转载请带上原文链接,感谢。 https://car.inotgo.com/2021/08/20210809022610336e.html