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

Example Analysis of practice with Python programming language

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail the example analysis on the practice of using Python programming language. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

As a matter of fact, Python is really interesting. I have done a lot of interesting things with Python. Here are some interesting things I have done.

Fun # 1: control the light bulb with Wechat

Set up an official Wechat account and set up to forward the request to your own official account server. Python is used to build a HTTP server on the official account server to get the request from Wechat. Then use Python to open one more thread, push the message to the local computer through TCP / UDP protocol, and the computer connects to the Arduino circuit board through the serial port. Python calls the serial module to communicate with the Arduino circuit board, and Arduino controls the behavior of the light bulb.

If you are interested, you can also connect Arduino to your home circuits, and with a bigger brain, you can use Wechat to control your air conditioner in the company.

Fun thing 2: color your favorite painting

Fun 3: picture processing

The fire pictures can be artistically processed by Python.

Fun 4: write a love confession program

Pip install wordclould

Then we need to make a background picture. In order to meet the emergency, I made a picture of Qixi Festival with art characters. If you don't have time to save the picture directly, you can use the following picture.

The code is as follows:

From wordcloud import WordCloudimport cv2import jiebaimport matplotlib.pyplot as plt# the following are the words you express your love: with open ('Flex hand QIXIZAQIXI. Txtress,' r') as f: text = f.read () cut_text = ".join (jieba.cut (text)) print (cut_text) # the following is color_mask = cv2.imread (" F:/520/mask.jpg ") 520cloud = WordCloud (font_path=" C:\\ Windows\\ Fonts\\ simkai.ttf "using the graph we just saved. Background_color='white', mask=color_mask, max_words=100, max_font_size=40) 520wCloud = 520cloud.generate (cut_text) 520wCloud.to_file ('Fjpg`) plt.imshow (520wCloud, interpolation='bilinear') plt.axis (' off') plt.show ()

This is the end of the sample analysis on the practice of using the Python programming language. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

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