Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Pycharm

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use Pycharm", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Pycharm" this article.

Pycharm is an efficient python IDE tool, it is very powerful, and can be cross-platform, is the first choice for beginners! Below, I would like to make a simple tutorial for friends who use this software for the first time. I hope it can help you!

At present, there are two versions of pycharm, Professional (Professional version) and Community Edition. Professional version is the most powerful, mainly for Python and web developers, and is paid for. The Community Edition is a professional version of the castrated version, which is relatively lightweight and is mainly prepared for Python and data experts. Generally speaking, it is more appropriate for us to do development and download a professional version.

I. introduction of common functions

1. Replace the Python interpreter

If you have multiple versions of python in your system and you want to change the interpreter, please use the following method:

Find Project Interpreter under File- > Setting- > Projec: xxx. Then change it to the Python interpreter you need. Note that it is important to note that when choosing the Python interpreter, be sure to choose the python.exe file instead of the python installation folder.

2. Create a new project

Let's build a new project, such as django.

3. Adjust the editor font and its size as well as the console font and its size

In File--settings

4. Set the file encoding

In File--settings

5. Modify file background color

In File--settings

6. Replace 4 spacebar with one tab key

7. Run the Python code

In pycharm, we do not need to run the program with the help of cmd under windows, pycharm provides the running function directly. After writing the program, we have three ways to run it:

If Toolbar is not displayed in the run in the toolbar, you can find Toolbar in view and check it.

The run button is also provided next to the run result.

Right-click and click run

8. Set the template

Set up a template in which you can put some settings or advertisements. You don't have to enter it every time you create a new file or template.

#! / usr/bin/env python #-*-coding:utf-8-*-# author: XXX

9. Breakpoints and debugging

The breakpoint feature can help us debug our code.

Set a breakpoint: you can set a breakpoint with a mouse click in the space between the front of the code and the line number. As follows:

Debug breakpoints:

Click the green beetle icon to debug the breakpoint.

After startup, automatically jumps to the first breakpoint. The breakpoint information is displayed in the debugger below.

Click Step Over or press F8, and we continue to run to the next breakpoint, where the current line information is displayed on the right!

2. Common and efficient methods of using pycharm

Positioning

Search Everywhere

Ctrl+ cursor

Recently opened file

The "radar" of directory tree

Find

Make up

Tab

The almighty Alt-Enter

Surroud with

Emmet

Editing

Basic

Extend Selection/ Shrink Selection

Multiple cursor

Reconstruct

Rename

Safe delete

Extract

Tuning

Face score

Other

Positioning

Search Everywhere

Shortcut key: double shift

You can search for file name, directory name (followed by /), class name, method name, and function name.

Ctrl+ cursor

When you hold down ctrl and move the mouse over the identifier, some information will be displayed.

When you hold down ctrl and click, you can jump to the definition

When you hold down ctrl and click at the definition, all references will be listed in a pop-up box, and when there is only one reference, it will jump directly.

Recently opened file

Ctrl-e

The "radar" of directory tree

Scroll from source.

The directory tree navigates to the location of the current file.

Find

Ctrl-f current file lookup

Shift-cmd-f global lookup

Directory tree right-click a directory, Find in Path, you can only search within this directory scope

Make up

Tab

Needless to say.

The almighty Alt-Enter

Different scenes have different actions. For example, when you press alt-enter in a variable that cannot find a reference, it pops up and lets you choose automatic import, create function parameters, rename to an existing variable, and so on.

Surroud with

Shortcut key: ctrl-alt-t

For example, use try...except... for the statement or block where the cursor is located Wrap it up.

Emmet

Emmet uses a specific syntax to expand small pieces of code, which is similar to the CSS selector, making it the complete HTML code. For example, the following sequence:

Div#page > div.logo+ul#navigation > li*5 > a

Will be expanded into:

Editing

Basic

Ctrl-c (copy). The current row is copied without a selection range, without the need to select the entire row before copying.

Ctrl-v (paste). Ctrl-shift-v can choose one of the clipboard history to paste.

Ctrl-x (cut)

Ctrl-s (Save)

Ctrl-z (undo). Ctrl-shift-z undo.

Ctrl-/ (comment). After commenting, the cursor automatically moves to the next line, making it easy to comment multiple lines.

Ctrl-d (copy lines)

Ctrl-shift-u (convert case)

Ctrl-alt-L (formatted)

Ctrl-alt-o (optimized import)

Shift-alt- ↑↓ (move up and down lines), shift-ctrl- ↑↓ (move up and down statements. A statement may have multiple lines. And will decide whether to go in and out of the block). To put it simply, one is a physical mobile line, and the other is a logical mobile statement.

Shift-enter (create a new line below). Ctrl-alt-enter opens a new line on it.

Alt- ←→ word level movement; ctrl- ←→ line beginning / end; shift- ←→ left and right move band selection; ctrl- [] block head / tail; cmd+ ↑↓ previous method / next method.

Cmd-L (Find/ Move to next Occurrence)

Extend Selection/ Shrink Selection

Expand the selection outward. I usually use it to select words, two quotation marks, or parentheses. Instead of using the mouse to choose.

Multiple cursor

Alt+ Click (or drag) and click again at a cursor to cancel the cursor.

Double-click Alt and press ↑ or ↓

Cmd-g (Add Selection for Next Occurrence)

Reconstruct

Rename

For example, if you change a variable rename, all the places where this variable is used will automatically change.

Safe delete

For example, delete a file, and delete all the places where the file is used.

Extract

Extract the selected code block to generate a new variable, attribute, method, parameter, etc.

Tuning

Help- > Edit Custom VM Options, configure more memory to make it smooth.

Disable useless plug-ins.

Face score

Install plug-in Material Theme UI. It looks a lot better.

Other

Pressing the same key before closing the symbol in the pairing symbol'")]} ignores and moves the cursor to the back without having to press the → key all the way.

Smart Keys (Preference- > Editor- > General- > Smart Keys Settings)

Insert a pair of quotation marks or parentheses when entering a single

Enter quotation marks or parentheses when selected, with quotation marks or parentheses on both sides without replacing the selection

Smart indent when wrapping

A backslash / is automatically spelled when wrapping lines within a statement

Automatically insert self when defining a method

"Reformat on paste" and "smart indent pasted lines"

Sage mode (do not disturb mode for coding)

New Scratch File. Used when temporarily editing files

Copy Reference. For example, right-click Copy Reference in a function and paste it into django shell to facilitate import.

Static analysis. For example, find out the duplicate code, check whether the code conforms to the pep8 and so on.

When you create a new file in the directory tree, you can create multiple layers with directories. Similar to the effect of mkdir-p. For example, enter foo/bar/baz.py, if there is no directory foo and bar, it will be created automatically.

After selecting in the editor, you can right-click "search with google" and "execute selected in console"

When editing the code, there will be a tag to the right of the line number. Insert, delete and modify are different tags. You can click to diff and rollback.

Right-click-> Local History in the directory tree to display the change history and restore to a certain history. (note: it has nothing to do with git)

The above is all the content of this article "how to use Pycharm". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report