You can learn Python articles without reading online classes (the first day)

Why_ does_ it_ work 2021-11-25 15:32:33
learn python articles reading online

Why learn python?

In the age of big data , Tiktok and Kwai Fu are all around the world. , Database of homework to help ape search questions , Are inseparable from big data , Scientific computing of big data , The most important language is python, Web crawler ( Web crawler - Sogou encyclopedia ) Search engines are also mainly python, Including some game images and so on python, The most important thing is that Baidu's artificial intelligence technology continues to improve , The rise of artificial intelligence , and ai So is the main language of intelligence python. The most magical python Can be mixed programming can be used c Language ,java Wait, hybrid programming , Then let's read an article together , introduction python.

Environment building

The compiler I use is pycharm

Generally speaking, download the community version ( Free version ) Ook , One set of services in place , Don't watch the video

Download PyCharm: Python IDE for Professional Developers by JetBrains


During the installation process

1、 Double click the downloaded PyCharm Installation package , The interface as shown in the figure below appears , Click on “next”.

2、 Select the installation directory ,Pycharm More memory required , It is recommended to install it in D Disk or E disc , Not recommended on system disk C disc .


3、 Make relevant settings , If you have no special need, just check the box in the picture .

Numbers 1:create desktop shortcut( Create a desktop shortcut ), System 32 You can choose 32-bit, System 64 You can choose 64-bit.
My computer is 64 Bit system , It automatically displays 64 position .
Numbers 2:update path variable(restart needed) Update path variables ( Reboot required ),add launchers dir to the path( Add the initiator directory to the path ).
Numbers 3:update context menu( Update context menu ),add open folder as project( Add open folder as project ). Add right mouse button menu , Open this shelf by opening the project . If you often need to download some other people's code to see , You can check this option , This will increase the right mouse button menu options . That is, you double-click on your computer py file , Will be used by default pycharm open .
Numbers 4:create associations create associations , relation .py file . Will all py The file is associated with pycharm.
4、 The default can be , Click on install.


installation is complete

5、 open PyCharm

Restart the computer , double-click PyCharm Turn on run .
 Insert picture description here

5、 ... and 、 To configure PyCharm

1、 Click on New Project Create a new project

 Insert picture description here

2、 Project settings

 Insert picture description here

3、 Environment configuration , It takes time



4、 establish python file


First set off a fireworks to check whether the operation is correct

# -*- coding: utf-8 -*-
import math, random,time
import threading
import tkinter as tk
import re
#import uuid
class firework(object):
def __init__(self,color,speed,width,height):
self.radius=random.randint(2,4) # The particle radius is 2~4 Pixels
self.color=color # Particle color
self.speed=speed #speed yes 1.5-3.5 second
self.status=0 # Without the fireworks exploding ,status=0; After the explosion ,status>=1; When status>100 when , The life of fireworks ends
self.nParticle=random.randint(20,30) # Number of particles[random.randint(0,width-1),random.randint(0,height-1)] # Fireworks random center coordinates
self.oneParticle=[] # Original particle coordinates (100% In the state of )
self.rotTheta=random.uniform(0,2*math.pi) # Rotation angle of elliptic plane
# Elliptic parametric equation :x=a*cos(theta),y=b*sin(theta)
for i in range(self.nParticle):
t=random.uniform(-1.0/16,1.0/16) # Produce a [-1/16,1/16) The random number
x,y=self.ellipsePara[0]*math.cos(theta*i+t), self.ellipsePara[1]*math.sin(theta*i+t) # Elliptic parametric equation
xx,yy=x*math.cos(self.rotTheta)-y*math.sin(self.rotTheta), y*math.cos(self.rotTheta)+x*math.sin(self.rotTheta) # Plane rotation equation
self.curParticle=self.oneParticle[0:] # Current particle coordinates
self.thread=threading.Thread(target=self.extend) # Create a thread object
def extend(self): # Particle swarm state change function
for i in range(100):
self.status+=1 # Update status identification
self.curParticle=[[one[0]*self.status/100, one[1]*self.status/100] for one in self.oneParticle] # Update particle swarm coordinates
def explode(self):
self.thread.setDaemon(True) # Set the current process as a daemon thread
self.thread.start() # Start thread
def __repr__(self):
return ('color:{color}\n'
'number of particle: {np}\n'
'center:[{cx} , {cy}]\n'
'ellipse:a={ea} , b={eb}\n'
def colorChange(fire):
f=lambda x,c: hex(int(int(x,16)*(100-c)/30))[2:] # When the particle life reaches 70% when , The color begins to decay linearly
if cs>70:
return '#{0:0>2}{1:0>2}{2:0>2}'.format(ccr,ccg,ccb)
def appendFirework(n=1): # Recursively generate fireworks objects
if n>maxFireworks or len(Fireworks)>maxFireworks:
elif n==1:
cl='#{0:0>6}'.format(hex(int(random.randint(0,16777215)))[2:]) # Produce a 0~16777215(0xFFFFFF) The random number , As a random color
Fireworks.append( {'particle':a,'points':[]} ) # Create a particle display list ,‘particle’ For a fireworks object ,‘points’ The object variable set displayed for each particle
def show(c):
for p in Fireworks: # Every time you refresh the display , First delete all the existing particles
for pp in p['points']:
for p in Fireworks: # According to each fireworks object , Calculate the display object of each particle
if oneP.status==100: # The status is marked as 100, It means that the life of fireworks is over
Fireworks.remove(p) # Remove the current fireworks
appendFirework() # Add a new fireworks
li=[[int(cp[0]*2)[0],int(cp[1]*2)[1]] for cp in oneP.curParticle] # Translate the ellipse whose center is the origin to the random center coordinates
color=colorChange(oneP) # Calculate the current color according to the current state of fireworks
for pp in li:
p['points'].append(c.create_oval(pp[0]-oneP.radius, pp[1]-oneP.radius, pp[0]+oneP.radius, pp[1]+oneP.radius, fill=color)) # Draw each particle of fireworks
root.after(50, show,c) # Callback , Every time 50ms Refresh once
if __name__=='__main__':
root = tk.Tk()
cv = tk.Canvas(root, height=height, width=width)
cv.create_rectangle(0, 0, width, height, fill="black")
root.after(50, show,cv)

本文为[Why_ does_ it_ work]所创,转载请带上原文链接,感谢

  1. Python爬虫编程思想(85):在Python中使用非关系型数据库
  2. Volume de réglage audio Python (avec Code) | outils Python
  3. Python crawler programming idea (59): get attribute value and text with beautiful soup CSS selector
  4. Python crawler programming idea (57): basic usage of CSS selector in beautiful soup
  5. Python crawler programming idea (55): find of beautiful soup method selector_ All method
  6. Python crawler programming idea (54): use beautiful soup to select sibling nodes
  7. Python crawler programming idea (53): use beautiful soup to select the parent node
  8. Django3.0 solves the problem of error reporting in reverse parsing
  9. Precautions for Python crawler
  10. Python 3 crawler series (1) -- climbing blind date websites
  11. Python到底是什么?为什么要学Python?
  12. #yyds干货盘点#Pandas数据清洗实用指南
  13. Python打包exe文件无法运行
  14. Two common ways to save files in Python
  15. #yyds幹貨盤點#Pandas數據清洗實用指南
  16. Yyds Dry Inventory pandas Data Cleaning Practical Guide
  17. PYTHON用LSTM长短期记忆神经网络的参数优化方法预测时间序列洗发水销售数据
  18. Python集成学习:自己编写构建AdaBoost分类模型可视化决策边界及sklearn包调用比较
  19. Python 3 makes a search software
  20. Python 3 simulated microblog login
  21. Using Python 3 to make practical software for drawing modification
  22. About HTML (acceptable to Python)
  23. Python集成學習:自己編寫構建AdaBoost分類模型可視化决策邊界及sklearn包調用比較
  24. PYTHON用LSTM長短期記憶神經網絡的參數優化方法預測時間序列洗發水銷售數據
  25. Python Integrated Learning: Writing and Constructing adaboost Classification Model Visualized decision Boundary and sklearn package Calling Comparison
  26. Python prédit les données de vente de shampooing de séries chronologiques en utilisant la méthode d'optimisation des paramètres du réseau neuronal de mémoire à court et à long terme lstm
  27. [zero basics of Python to introduction] a prerequisite for Python preparatory knowledge -- basic coding specification of Python
  28. OpenCV对比度亮度变换竟能用来去水印(附Python/C++源码)
  29. [zero basics of Python to getting started] a prerequisite for Python preparatory knowledge -- installing the visualization tool pycharm
  30. The test modifies in micro python
  31. Microphoton experimental circuit board based on mm32f3273 - does not work normally
  32. Run micropathon on mm32f3273 to test performance
  33. Design mm32f3277 micro Python experimental board with SD card
  34. Mm32f3277 corresponding interface files during microphoton migration
  35. Mm32f3277 microphoton experimental board design and software testing
  36. Making and testing mm32f3277 microphoton minimum circuit board
  37. Download mm32-link program automatically with Python simulated mouse
  38. A curriculum of "artificial intelligence Python machine learning and deep learning"
  39. Test the basic functions of mm32 microphoton test circuit board
  40. Test the basic functions of the mm32f3277 micro Python development board flying one by one
  41. Debugging mm32f3277 from zhufei, transplanted with micro Python development board
  42. Recognizing numbers using OpenCV and python
  43. 真的太香了,Python速查表终于出中文版了
  44. Django REST Framework(DRF)教程:快速入门
  45. python django objects filter过滤查询:startswith year
  46. Data encapsulation of Excel test cases in Python
  47. 学员管理系统python
  48. 肝了一夜,8000字概括精髓,pandas必知必会50例!
  49. Python竟然可以画漫画!漫画版的故宫导游图,来袭!
  50. Networkx graph theory Dijkstra algorithm shortest path implementation, Python
  51. Draw a HelloWorld with Python turtle Library
  52. 运行django的服务器内存使用偶尔跳高一点,重启服务马上下来,是内存泄露吧
  53. Basic usage of Python tqdm module in machine learning training
  54. Python -- basic usage method and basic template of argparse module
  55. python-sockertserver并发编程思想
  56. Programmation simultanée du serveur de sockets Python
  57. Vue+Django 旅游网项目 首页前端实现
  58. Classic usage of pandas: iloc and LOC of data filtering
  59. Calendar module of Python time series
  60. A super easy to use Python standard library. It's great to operate directories and files