Python工具篇(二):Pycharm簡介

Pycharm用戶手冊:https://www.jetbrains.com/help/pycharm/quick-start-guide.html
editions comparison matrix
之前都用的vscode,初次接觸pycharm,以免費的社區版爲例,將用戶手冊中的一些內容搬運一些以便之後查閱

key map

Ctrl+Alt+T: quickly surrounding your code with complete constructs
Shift+F10: Run
Shift+F9: Debug
Ctrl+/: Comment and Uncomment Blocks of Code
Ctrl+點擊模塊名等: 查看源碼
Shift+Enter: 換行
Ctrl+Shift+ - : 將文件內的所有代碼塊全部摺疊

Ctrl+F: find and replace any fragment of code in the currently opened file
Ctrl+Shift+F: find and replace any fragment of code in the currently opened file
Alt+F7: full-scale search via Find Usages
Double Shift: Search Everywhere

Get started

Step 1. Open/Create a project in PyCharm

Open an existing project

在這裏插入圖片描述

It is also possible to drag an existing project directory or a separate file to the Welcome screen, and open it in PyCharm.

Check out an existing project from Version Control

在這裏插入圖片描述

Create a project from scratch

在這裏插入圖片描述

  • 最上面的Location爲工程存放的地址
  • New environment選項是創建一個新的虛擬環境,其中的Location爲新的虛擬環境的存放地址,Conda executable路徑選擇如圖所示
  • Existing Interpreter中的Interpreter選擇anaconda安裝地址中的python解釋器

Creating a Python file

在這裏插入圖片描述
在這裏插入圖片描述

Configure project interpreter

When you configure a project Python interpreter, you need to specify the path to the Python executable in your system. You can create several project interpreters based on the same Python executable. This is helpful when you need to create different virtual environments for developing different types of applications.
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
創建完成之後使用命令行查看,確實新建了一個虛擬環境
在這裏插入圖片描述

Step 2. Look around

Terminal, Python console

可以看到在左下角有一個很小的圖標:
在這裏插入圖片描述
將鼠標懸浮在上面,可以看到可以開啓以下窗口:
在這裏插入圖片描述
其中就包括了Python終端以及默認激活了工程所用虛擬環境的命令行窗口:
在這裏插入圖片描述

在這裏插入圖片描述

TODO (to do)

在這裏插入圖片描述
在這裏插入圖片描述
雙擊即可回到上次寫的TODO位置

copy file path

在這裏插入圖片描述

Step 3. Customize your environment

Appearance

在這裏插入圖片描述
在這裏選擇Pycharm的顏色主題。這裏還是選擇護眼的黑色吧。

Editor

在這裏插入圖片描述

Code style

在這裏插入圖片描述

Step 4. Generate some code

consider quickly surrounding your code with complete constructs(Ctrl+Alt+T)
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

Step 5. Find your way through

Basic search

You can find and replace any fragment of code both in the currently opened file Ctrl+F, or in an entire project Ctrl+Shift+F.

Search for usages

To find where a particular symbol is used, PyCharm suggests full-scale search via Find Usages Alt+F7:
在這裏插入圖片描述

Project navigation

在這裏插入圖片描述

Search Everywhere

click the magnifying glass button in the upper right-hand corner of the window, or invoke it with Double Shift (press Shift twice).
在這裏插入圖片描述
在這裏插入圖片描述

Step 6. Run, debug and test

Run / Debug

Run: Shift+F10 Debug: Shift+F9
在這裏插入圖片描述

Run configuration

When you perform run, debug, or test operations with PyCharm, you always start a process based on one of the existing run/debug configurations, using its parameters.

When you run your application for the very first time, PyCharm automatically creates the temporary Run/Debug configuration. You can modify it to specify or alter the default parameters and save it as a permanent Run/Debug configuration.
在這裏插入圖片描述
For example, if you want to run some script before/after the build phase, you can do this easily by creating an external tool:
在這裏插入圖片描述

Step 9. Keep your source code under Version Control

more detailed information

VCS

PyCharm integrates with many popular version control systems: Git (or GitHub), Mercurial, Perforce (supported in Professional edition only), Subversion.
在這裏插入圖片描述

Local history

In addition to traditional version control, you can use the local history. With Local History, PyCharm automatically tracks changes you make to the source code, the results of refactoring, and so on

Local history is always enabled.

在這裏插入圖片描述
在這裏插入圖片描述

Configuring PyCharm settings

In PyCharm, you can configure the settings on two levels: the project level and globally.
在這裏插入圖片描述
在這裏插入圖片描述

Restore IDE settings

restore the defaults

在這裏插入圖片描述

restore your settings from backup

When you restore the default IDE settings, PyCharm backs up your configuration to a directory.
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

Manage plugins

在這裏插入圖片描述
因爲之前也沒用過Pycharm,先在網上隨便找了幾個聽說好用的插件試試看
參考地址:
https://blog.csdn.net/stormdony/article/details/90261391
https://zhuanlan.zhihu.com/p/98096152

Material Theme UI

Mongo Plugin

Markdown support

Markdown Navigator(Paid)

Key Promote X

Json Parser

Rainbow Brackets

.ignore

Compare files

Compare two files

  1. Select the files you want to compare in the Project tool window.
  2. From the context menu, choose Compare Files, or press Ctrl+D.

You can also select one file, choose Compare With from the context menu, and select a file that is outside your project.

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

Compare active editor with Clipboard

Right-click anywhere in the editor and choose Compare with Clipboard from the context menu.
在這裏插入圖片描述

Compare active editor with a project file

  1. Right-click the file you want to compare with the currently opened file in the Project tool window.
  2. Choose Compare File with Editor from the context menu.

File encoding

Configure encoding for a directory or a file without built-in encoding information

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

Change encoding of a single file that doesn’t contain explicit encoding

在這裏插入圖片描述

Change encoding of a project

在這裏插入圖片描述
在這裏插入圖片描述

File and code templates

在這裏插入圖片描述
這樣的話之後每次新建python文件時,這幾行就會出現在新文件的開頭

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章