程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[python learning 1] pycharm installation and use

編輯:Python

(1) pycharm installation

pycharm can be downloaded from the software store or official website community (community version), the community version software can be used for free

(2) pycharm use

1, New project:

As can be seen from the above figure ①pycharmuses its own venv virtual running environment by default, which can make the installation package and running environment of each project independent of each other.

②pycharm uses the python interpreter that comes with the computer, you need to install the python interpreter on the computer in advance (you can download it from the official website)

③You can also choose the Previously configured interpreter option below, then the Venv part above will be grayed out and not selectable, in the Previously configured interpreter column Select the python.exe file downloaded by the computer.The venv virtual environment is not used at this time, and the python environment downloaded by the computer is used, so there is no need to import many packages or modules

Special reminder: The command side in pycharm and the command side of Windows can use the same command, but since pycharm has a venv virtual operating environment, the python installation library function retrieved from the command side of WindowsUnlike pycharm, the required library functions must be re-downloaded in venv, and the environment configuration and the introduction of third-party libraries need to be performed on the venv of each pycharm project.(Use the pip list command to retrieve installed library functions)

When downloading a third-party library, since pycharm is a foreign software, the built-in mirror source is located abroad, so the download is very slow, so it is necessary to replace the mirror source

2, the download and introduction of third-party libraries in venv

The first type: Change the mirror source and download the third-party library: File ->Settings ->Project:pythonProject ->Python Interpreter ->"+" ->Search the installed library -> Manage Repositories -> replace the mirror source -> exit and click to download the library

Second : Use the command line to install, open the terminal of pycharm, and enter pip install matplotlib (library function name).ready to download

Special attention: The third-party libraries downloaded above all exist in the virtual environment of the project and will not affect other projects

The first method is as follows:

The second method is shown in the figure:

 

Attach the mirror source URL:

Tsinghua mirror source: https://pypi.tuna.tsinghua.edu.cn/simple

University of Science and Technology of China mirror source: https://pypi.mirrors.ustc.edu.cn/simple/

Alibaba Cloud Mirror Source: http://mirrors.aliyun.com/pypi/simple/

3, pycharm common shortcut keys

(1)Open settings: ctrl+alt+s (2) Run the current code: ctrl+shift+F10

(3) Run the current script: shift+F10

(4) Find: ctrl+f (find content in the current file) Global search: ctrl+shift+f (find in all files in the project)

(5) Replacement: ctrl+R Global replacement: ctrl+shift+r

(6) Indent: tab Reverse indent: shift+tab (7) Turn page: PageUp,PageDown

(8) The cursor is at the beginning of the line: Home End of the line: End

(9) Quick correction of python code: alt+enter (reformat file to reorganize the file format, used to solve the problem of yellow wavy lines that do not conform to the python format)

(10) Quick comment: ctrl+/ (comment all selected lines)

(11) Copy code: ctrl+D (when the cursor is placed on a line, copy the line of code; when the cursor selects a part of the content, copy the selected content)

(12) Delete code: ctrl+Y (delete the line when placed in a line)

(13) Renaming of project or file: shift+F6

(14) Insert code down: shift+enter Insert code up: ctrl+alt+enter (when the cursor is placed on a line, the code will be inserted in the upper or lower line of the current line)

(15) View project view: alt+1 View structure view: alt+7

(16) Quickly enter the code: ctrl+left mouse button (enter the source code or defined function)

(17) Quickly view history: alt + left and right mouse buttons (view and return of history, as a switch between the source file and the current file)

(18) Switch the open file view in pycharm: ctrl+tab

Additional features:

(1) The structure column in the upper left corner of pycharm can display the structure, objects, functions and classes of the code, which is convenient for understanding the program

(2) View the installed libraries of the project: the External Libraries -> site-packages option in the upper left, click to view the installed library functions

(3) For special files such as: html web page files, you can right-click the file -> Open In -> there are Explorer (resource manager, display the location of the file), Browser (browser, used to open the html file)

(4) TODO comments and top-down programming thinking: Format: TODO ("to be improved or other functions"), used to mark unfinished parts of the code, which will be improved later; mainly used for top-downThe development method is to write the main framework first, and then improve the related modules later.
    There is a TODO view in the lower right corner, you can view the location of TODO

(5) File ->Settings ->Editor ->Font can change the font size
    File ->Settings ->Editor ->Code Style ->File and Code Templayes can create templates for different types of files


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved