In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to use the Pycharm editor function to automatically generate formats". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Theme
As mentioned earlier, Pycharm has powerful spelling prompts, including basic and smart type. In addition, Pycharm can automatically generate some structured code and insert pairs of curly braces and quotation marks.
2. Indent automatically
Type the class declaration, and then enter:
The Pycharm cursor is automatically indented, where you can start entering the function declaration:
At this point, the mechanism for automatic indentation has been started. Here the function declaration (and all nested operations) is indented 4 spaces from the left by default. The indentation rules here involve Python's relatively fixed code style standard, and this standard is customized according to your team (that is, a company needs to follow a uniform standard). After specifying the standard, Pycharm will help us maintain the code style according to the standard. Next, we will show you exactly how Pycharm implements this function. Also take this simple code as an example, open the settings dialog box, expand the Code Style node, and open the Python page (Ctrl+Alt+S → Project Settings → Code Style → Python):
As you can see, the indentation size specified here is 4 spaces, and Pycharm follows this rule for automatic code generation and format checking reformatting. Of course, we change the indentation rules (just like other code rules). Suppose you want to indent 5 spaces, that is, all new code generated will be indented 5 spaces relative to the upper code. Browse the Smart Keys page for more detailed information.
However, the default code style framework of Pycharm is immutable. Pycharm will automatically make a copy of it for us to modify before making a private customization:
This new configuration framework is saved in your user directory, and you can share it with other teammates if necessary, so that the style of the code of the whole team can be unified. For more information on code style settings, see Project and IDE Settings.
3. Automatic grammar completion
When you enter a parenthesis (Pycharm will try to complete the other half), Pycharm will complete the system parameter self. After entering, the cursor will move to the next input position (according to the current indentation rule), enter the information you need to print here, enter a parenthesis, and Pycharm will automatically complete the other half of the parentheses and place the cursor inside the parentheses so that we can enter the information to be printed:
Next, let's test a more complex situation-- editing a Django template. For Django templates whose syntax is very complex, the syntax auto-completion function is very important. OK, start entering a Django tag
Once you type a curly bracket, Pycharm automatically completes the other one:
And the cursor will stop between two%, making it easy for us to enter the code:
Similarly, for the {{flag Pycharm will also automatically complete the other half.
The relevant settings of the syntax auto-completion feature are located on the Smart Keys page of the editor settings: Ctrl+Alt+S → IDE Settings → Editor → Smart Keys:
For example, if you want Pycharm to automatically complete parentheses, square brackets, and so on, you need to check the Insert pair bracket check box; to automatically complete quotation marks, you need to check the Insert pair quote check box. For Django templates, there is a special check box Auto-insert closing}} and%} in Django templates to choose from.
This is the end of the content of "how to use the Pycharm editor to automatically generate formats". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.