Script to tweet with multiples of 3 and numbers with 3 !!

Use python twitter tools.

pip install twitter

Next, register the twitter app at https://apps.twitter.com/. At this time, set the Access level to Read and write. Make the necessary registrations to get the API key, API secret, Access token, and Access token secret.

Execute the following script.

from twitter import *

api_key = "My api key"
api_secret = "My api secret"
access_token = "My access token"
access_token_secret = "My access token secret"


twitter = Twitter(auth=OAuth(access_token, access_token_secret, api_key, api_secret))

text = 'Only multiples of 3 and numbers with 3!!Execute the script to tweet with'
twitter.statuses.update(status=text)

tweet = []
for i in range(1,31):
    if i % 3 == 0:
        tweet.append(str(i) + '!!')

    elif '3' in str(i):
        tweet.append(str(i) + '!!')

    else:
        tweet.append(str(i))

tweet = " ".join(tweet)

twitter.statuses.update(status=tweet)

result ![tweet.PNG](https://qiita-image-store.s3.amazonaws.com/0/37662/30031e7a-fbd2-5904-e968-7867ba8a6ffa.png)
【reference】 [Notes on using Python Twitter Tools](http://www.geocities.jp/showa_yojyo/note/python-twitter-tools.html) [hirooka.pro Python Twitter Tools](https://hirooka.pro/?p=2252)

Recommended Posts

Script to tweet with multiples of 3 and numbers with 3 !!
Converts numbers with commas and triangles to numeric types.
Sorting with mixed numbers and letters
I don't like to be frustrated with the release of Pokemon Go, so I made a script to detect the release and tweet it
Script to tweet after n seconds
Coexistence of Python2 and 3 with CircleCI (1.0)
Aggregation and visualization of accumulated numbers
Correspondence analysis of sentences with COTOHA API and save to file
I tried to create a list of prime numbers with python
To improve the reusability and maintainability of workflows created with Luigi
[Blender] How to set shape_key with script
Import of japandas with pandas 1.0 and above
Script to change the description of fasta
Execute Python script with cron of TS-220
I tried to take the difference of Config before and after work with pyATS / Genie self-made script
Fractal to make and play with Python
Wrap reading and writing of GCP to Secret Manager with google subcommands
Script example to display BoundingBox with PIL
Tweet analysis with Python, Mecab and CaboCha
Python code to train and test with Custom Vision of Cognitive Service
Project Euler # 1 "Multiples of 3 and 5" in Python
Try to separate the background and moving object of the video with OpenCV
Story of making a virtual planetarium [Until a beginner makes a model with a script and manages to put it together]
Solve with Ruby and Python AtCoder ABC084 D Cumulative sum of prime numbers
Specify the start and end positions of files to be included with qiitap
Distinguish between numbers and letters with regular expressions
Scraping tabelog with python and outputting to CSV
Convert data with shape (number of data, 1) to (number of data,) with numpy.
Learn to recognize handwritten numbers (MNIST) with Caffe
[Cocos2d-x 3.0] How to automate Script Binding with binding-generator
How to specify attributes with Mock of python
Ten Puzzle-Make 10 with only 4 numbers and 4 arithmetic operations
How to implement "named_scope" of RubyOnRails with Django
Story of trying to use tensorboard with pytorch
[Improved version] Script to monitor CPU with Python
Implementation of TRIE tree with Python and LOUDS
Wavelet transform of images with PyWavelets and OpenCV
List of Python code to move and remember
Continuation of multi-platform development with Electron and Python
Python script to get note information with REAPER
Example of reading and writing CSV with Python
How to create random numbers with NumPy's random module
Extract images and tables from pdf with python to reduce the burden of reporting
I tried to automate the article update of Livedoor blog with Python and selenium.
Compress variables such as DataFrame with joblib instead of pickle to read and write
The story of trying to contribute to COVID-19 analysis with AWS free tier and failing
I just wanted to extract the data of the desired date and time with Django
I tried to compare the processing speed with dplyr of R and pandas of Python
Procedure to load MNIST with python and output to png
[Python] Convert decimal numbers to binary numbers, octal numbers, and hexadecimal numbers
How to add help to HDA (with Python script bonus)
A memo connected to HiveServer2 of EMR with python
Template of python script to read the contents of the file
I tried to extract features with SIFT of OpenCV
Convert a slice object to a list of index numbers
I tried to read and save automatically with VOICEROID2 2
Display embedded images of mp3 and flac with mutagen
Easy IoT to start with Raspberry Pi and MESH
I tried to implement and learn DCGAN with PyTorch
Script to cancel an instance of Bluemix-IaaS (formerly SoftLayer)
I want to handle optimization with python and cplex