Article directory
Learn about pycharm
-
Run Pycharm, select Create New Project, and create a new Python project.
-
Select 'Pure Python' to create a new pure Python project, Location indicates the save path of the project, and Interpreter is used to specify the version of the Python interpreter.
-
Right-click on the project, select New, then select Python File
-
Enter the file name HelloPython in the pop-up dialog box, and click OK to create a text file of a Python program. The default extension of the text file is .py
-
In the newly created HelloPython.py file, enter the following code, and right-click in the blank space to select Run to run, which means output a hello world string.
print("hello world!")
- After running successfully, the Pycharm Console window will display our output.
interactive programming
Simply put, it is to run the interpreter directly in the terminal instead of using the file name to execute the file. This interactive programming environment, we can also call it REPL, which reads (Read) the input content, executes (Eval) the instructions entered by the user, prints (Print) the execution results, and then loops (Loop), Python Supports interactive programming.
1. Python interactive programming
2. Enter interactive programming in Pycharm
3. Installation and use of IPython
The interactive programming that comes with pyton is not powerful enough. For example, it cannot implement functions such as syntax highlighting and automatic line break. You can use the third-party package IPython (Interactive Python) to extend the functions of the built-in Python shell.
Install IPython
Using the pip command, you can quickly install IPython.
pip install ipython
use IPython
Enter ipython on the command line to enter ipython interactive programming.
Compared
Fourth, the advantages and disadvantages of interactive programming
advantage:
- Suitable for learning/validating Python syntax or partial code
shortcoming:
- Code cannot be saved
- Not suitable for running very large programs
note
In the process of our work coding, if the logic of a piece of code is complex and not particularly easy to understand, we can add comments appropriately to assist ourselves or other coders to interpret the code.
Note: Comments are for programmers. In order to make it easier for programmers to read the code, the interpreter will ignore comments. It is a good coding habit to use the language you are familiar with and properly comment on the code.
Classification of comments
Single-line comments and multi-line comments are supported in Python.
single line comment
Starting with #, everything on the right of # is used as an explanation, not the actual program to be executed, and serves as an auxiliary explanation.
# #开头右边的都是注释,解析器会忽略注释
print('hello world') #我的作用是在控制台输出hello world
multiline comment
Starting with ''' and ending with ''', we call it a multi-line comment.
'''
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
佛祖保佑 永无BUG
佛曰:
写字楼里写字间,写字间里程序员;
程序人员写程序,又拿程序换酒钱。
酒醒只在网上坐,酒醉还来网下眠;
酒醉酒醒日复日,网上网下年复年。
但愿老死电脑间,不愿鞠躬老板前;
奔驰宝马贵者趣,公交自行程序员。
别人笑我忒疯癫,我笑自己命太贱;
不见满街漂亮妹,哪个归得程序员?
'''
Advanced case
[Python] Python realizes the word guessing game-challenge your intelligence and luck!
[python] Python tkinter library implements GUI program for weight unit converter
[python] Use Selenium to get (2023 Blog Star) entries
Use Tencent Cloud Cloud studio to realize scheduling Baidu AI to realize text recognition
[Xiaobai must see] Python word cloud generator detailed analysis and code implementation
[Xiaobai must see] Python crawls an example of NBA player data
[Must-see for Xiaobai] Sample code for crawling and saving Himalayan audio using Python
[Xiaobai must see] Python crawler data processing and visualization
[Must-see for Xiaobai] Python crawler program to easily obtain hero skin pictures of King of Glory
[Must-see for Xiaobai] Use Python to generate a personalized list Word document
Geospatial data processing and visualization using geopandas and shapely (.shp)
Use selenium to crawl Maoyan movie list data
Detailed explanation of the principle and implementation of image enhancement algorithm Retinex
Getting Started Guide to Crawlers (8): Write weather data crawler programs for visual analysis
Getting started with crawlers (4): The best way to crawl dynamic web pages using Selenium and API
Getting Started Guide to Crawlers (3): Python network requests and common anti-crawler strategies
Getting started with crawlers (2): How to use regular expressions for data extraction and processing
Getting started with reptiles (1): Learn the basics and skills of reptiles
Python object-oriented programming basics and sample code
MySQL database operation guide: learn how to use Python to add, delete, modify and query operations
Python file operation guide: encoding, reading, writing and exception handling
Selenium Automation Toolset - Complete Guide and Tutorials
Python web crawler basics advanced to actual combat tutorial
Pandas data processing and analysis tutorial: from basics to actual combat
Detailed explanation of commonly used data types and related operations in Python
[Latest in 2023] Detailed Explanation of Six Major Schemes to Improve Index of Classification Model