1590375045
現在2つの同じフォーマットで作られたエクセルを比較するスクリプトを書いています。その操作をGUI上
#python #tkinner #gui #programmer
1649149359
Do you use Twitter? If so, then you must come across some of the bots that like, retweet, follow, or even reply to your tweets. But have you ever wondered how they are made? Well, it's easy as filling water in a bottle. Haha! It's really not rocket science. So, let's get started and make a bot.
In Python, the twitter bot is just a few lines of code, less than 30.
- tweepy module in Python.
- A twitter account, which you want to make a bot.
- Twitter developer account.
To apply for the developer account on twitter, follow these steps:
Make sure you've logged in to your Twitter account on which you want to make a bot.
Here, I'm using my new account BashWoman to make a bot, which will like, and retweet the hashtag #python3.
And
Else select no, just to keep it simple. Enter all the details you'd do with this bot.
Click Get keys.
You see there are no more than 30 lines in Python. Let's understand each and every line.
import tweepy
import time
To communicate with Twitter API, we need some module, here we are using tweepy. You can install it easily.
pip install tweepy
Once you install the module, write some more code.
# Authenticate to Twitter
CONSUMER_KEY = '<your-consumer-or-API-key-goes-here>'
CONSUMER_SECRET = '<your-consumer-or-API-secret-goes-here>'
ACCESS_KEY = '<your-access-key-goes-here>'
ACESS_SECRET = '<your-access-secret-goes-here>'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACESS_SECRET)
This is used to authenticate your Twitter account. Remember these keys are of your account, don't share them to anyone, else they can access your data. That's why I have made some variables in which I will store the keys.
These keys will be found in your developer account, which you've saved a time ago.
auth variable is created to authenticate the account, Twitter uses OAuth to do this.
And, after that, we will set the tokens.
# Create API object
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
This class provides a wrapper for the API as provided by Twitter. If you stuck somewhere, you can always refer to the tweepy documentation.
user = api.me()
search = '#python3'
numTweet = 500
for tweet in tweepy.Cursor(api.search, search).items(numTweet):
try:
print('Tweet Liked')
tweet.favorite()
print("Retweet done")
tweet.retweet()
time.sleep(10)
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break
Finally, we will tell the program to look for the keyword #python3 in a tweet and the number of tweets that will be processed once in a day. If you want to like, you can use tweepy.favorite() , and for retweet tweepy.retweet(). The reason, I'm using sleep is, twitter has some guidelines, you must follow otherwise, your account will be restricted. There is a limit for liking the number of tweets. If it gives some error, we can use tweepy.TweepError so that we know, what went wrong.
Now, it's time for the deployment. You can use any platform, I have used Render.
After creating an account on this, create a cron job, you can schedule the time, I prefer about 10 to 15 mins. It means your bot will run every 10 to 15 mins so that it won't violate the Twitter guidelines and your account will be safe and not get restricted.
Here's my bot.
It's time to build your own bot. All the best.
Author: Kunal-Diwan
Download Link: Download The Source Code
Official Website: https://github.com/Kunal-Diwan/TwitterBot
License: AGPL-3.0 License
1591710480
Python is a powerful, friendly and easy to learn programming language. At the writing time of this article Python 3.8 latest stable version is available to download and install.
This article will help you to install Python 3.8 from source on your CentOS 8 and RHEL 8 Linux systems.
#python #centos 8 #python3 #python3.8
1627200000
Installing Virtualenv with Python3 | VirtualEnv for Django | Django Tutorials for beginners 2021.
In this video you will see how to install virtual environment and using it with python3.
#virtualenv #python3
1625171280
Have you ever looked at a Kubernetes manifest and thought to yourself “I really don’t want to write this in YAML”?
TRUST ME, you’re not alone!
Luckily, you don’t have to. You can use Python to do it all for you!
In this video, you’ll learn how to create a Kubernetes manifest written PURELY in Python.
Let’s jump right in!
👊Join The Cloud and DevOps Movement 👊
https://cloudskills.io/
Twitter: https://twitter.com/TheNJDevOpsGuy
Blog:https://www.michaellevan.net/
#python3 #python #kubernetes
1592815080
Sublime Text is one of the most widely used lightweight text editors when it comes to programming. If you’re a Python programmer, you may not be running your preferred version of Python. This tutorial explains how to get Sublime Text running Python 3.7.
Check Which Version Your Sublime Text is Using
Create a new Python file. I called mine scratch.py. It’s important that you save your file as a .py extension before running Python code. Otherwise, you won’t be able to execute Python code. Also, it’s always nice to have a scratch Python file to run quick code.
#python3 #python #mac #sublimetext #sublime