In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the fun Python technologies". In the daily operation, I believe many people have doubts about the fun Python technology. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the fun Python technologies?" Next, please follow the editor to study!
Because the following code is very simple, simple enough to be done directly in an interactive environment using Python. Of course, the interactive environment that comes with the official Python is difficult to use. It is recommended that you use ipython. You can use the following command to install ipython. After the installation is successful, type the ipython command to enter the interactive environment.
Pip install ipython
Or
Pip3 install ipython
The most intuitive advantages of ipython:
Can you use it? Or?? To get help.
It works! Invoke system commands.
You can use the Tab key to automatically complete.
Magic instructions can be used, such as% timeit.
P-diagrams can be done without tools and code.
1. Install the pillow Triple Library.
PIL (Python Imaging Library) is the de facto standard library for image processing on the Python platform. PIL is very powerful, while API is very easy to use. But PIL only supports Python 2.7, and no one has maintained it for many years, so a group of volunteers created a compatible version based on PIL, called Pillow, which not only supports Python 3.x, but also adds a lot of useful and interesting new features.
Pip install pillow
Or
Pip3 install pillow
2. Load the picture.
From PIL import Imagechiling = Image.open ('chiling.jpg') chiling.show ()
3. Use the filter.
From PIL import ImageFilterchiling.filter (ImageFilter.EMBOSS). Show () chiling.filter (ImageFilter.CONTOUR). Show ()
4. Image clipping and pasting.
Rect = 220690265,740 watch = chiling.crop (rect) watch.show () blured_watch = watch.filter (ImageFilter.GaussianBlur (4)) chiling.paste (blured_watch, (220,690)) chiling.show ()
5. Generate a mirror image.
Chiling2 = chiling.transpose (Image.FLIP_LEFT_RIGHT) chiling2.show ()
6. Generate thumbnails.
Width, height = chiling.sizewidth, height = int (width * 0.4), int (height * 0.4) chiling.thumbnail ((width, height))
7. Synthesize the picture.
Frame = Image.open ('frame.jpg') frame.show () frame.paste (chiling, (210,150)) frame.paste (chiling2, (522,150)) frame.show ()
Bless the video to the Wechat friend group fa
1. Install the itchat Triple Library.
Itchat is an open source Wechat personal ID interface. It has never been easier to use Python to call Wechat.
Pip install itchat
Or
Pip3 install itchat
2. Log on to Wechat.
Import itchatitchat.auto_login ()
Description: use your own Wechat to scan the QR code that appears on the screen to complete the login operation. Only after logging in can you get your friend information and send messages to your friends.
3. Find your friends.
Friends_list = itchat.get_friends (update=True) print (len (friends_list)) luohao = friends_list [0] props = ['NickName',' Signature', 'Sex'] for prop in props: print (Luohao [prop])
[description]: friends_list is equivalent to a list, and the first element in the list is itself.
4. Randomly select 5 friends and get their user names, nicknames and signatures.
Lucky_friends = random.sample (friends_list [1:], 5) props = ['NickName',' Signature', 'City'] for friend in lucky_friends: for prop in props: print (Friendship [Prop] or' does not have this information') print ('-'* 80)
5. Send text messages to friends.
Itchat.send_msg ('in urgent need of a red packet to save the fallen soul!' , toUserName='@8e06606db03f0e28d0ff884083f727e6')
6. Group fa videos for lucky friends.
Lucky_friends = random.sample (friends_list [1:], 5) for friend in lucky_friends: username = friend ['UserName'] itchat.send_video (' / Users/Hao/Desktop/my_test_video.mp4', toUserName=username)
There are many other things that can be done with itchat. For example, some friends send messages to themselves and then withdraw them. If you want to view these withdrawn messages, itchat can do it. For example, sometimes we want to know whether a friend has deleted or blacklisted us. We can also use the group chat feature encapsulated by itchat. Non-friends and blacklist users will not be pulled into the group chat. You can determine the relationship between you and the specified person by creating the return value of the group chat function.
You don't need the client to view hot news.
Install the requests library.
Pip install requests
Or
Pip3 install requests
2. Crawl news data or get news data through API interface.
Import requestsresp = requests.get ('http://api.tianapi.com/allnews/?key=, please use the Key&col=7&num=50' you applied for)
Note: the above uses the data interface provided by Skyline data. If necessary, you can go to the website of Skyline data to register and activate. When calling the API, fill in the key assigned to you by the system after successful registration.
3. Use deserialization to parse the JSON string into a dictionary and get the news list.
Import jsonnewslist = json.loads (resp.text) ['newslist']
4. Cycle through the news list to find news of interest, such as Huawei.
For news in newslist: title = news ['title'] url = news [' url'] if 'Huawei' in title: print (title) print (url)
5. Call the SMS gateway to send a text message to the phone, tell the news title and give the link.
Import repattern = re.compile (ringing https auth=:\ / [^\ /] *\ / (? P.*)') matcher = pattern.match (url) if matcher: url= matcher.group ('url') resp = requests.post (url=' https auth= (' api', 'key- please use the Key' you applied for), data= {' mobile': '13548041193' 'message': f' found a piece of news that you might be interested in-{title} Click https://news.china.com/{url} for details. [Python lesson]'}, timeout=10, verify=False) at this point, the study of "what are the fun Python technologies" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.