Python Forum
How to convert a Status object to String?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert a Status object to String?
#1
Really need some help, been stuck on this for hours. So I'm working on a small Twitter bot that is using Tweepy.

I have it working so that when my Twitter account gets mentioned in a Tweet I grab what the tweet says and run it through a function that will determine what my reply is. The big issue I have is that when I get a copy of the tweet that I was in, it includes my Twitter username which will make my reply not work. For example: "@mytwitteraccount their message" I only need the "their message" part of it.

I thought the best way to remove my username from the output with there tweet was to do
s = "@mytwitter their message"
' '.join(s.split()[1:])
the problem I've been having is since the output isn't a String It won't work. I've tried str() no luck.

Heres my code for what I'm doing to get the tweet.

tweets = api.search(q="@myaccount",count=100,include_entities=True)
t = ['@myaccount', '@MyAccount']

for s in tweets:
    sn = s.user.screen_name
    m = "@%s my reply" % (sn)
    s = api.update_status(m, s.id)

for result in tweets:
    print (result.text)
Any help would be great, I looked over the Tweepy Documentation and couldn't find anything.
Reply


Messages In This Thread
How to convert a Status object to String? - by Vucko - Jan-14-2018, 06:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert address and broadcast to network object Skaperen 9 1,973 Mar-09-2023, 06:55 PM
Last Post: Skaperen
  convert string to float in list jacklee26 6 2,055 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 2,167 Dec-17-2022, 12:24 AM
Last Post: snippsat
  how to convert tuple value into string mg24 2 2,543 Oct-06-2022, 08:13 AM
Last Post: DeaD_EyE
  Convert string to float problem vasik006 8 3,574 Jun-03-2022, 06:41 PM
Last Post: deanhystad
  Convert a string to a function mikepy 8 2,720 May-13-2022, 07:28 PM
Last Post: mikepy
Question How to convert string to variable? chatguy 5 2,678 Apr-12-2022, 08:31 PM
Last Post: buran
  Convert string to int Frankduc 8 2,610 Feb-13-2022, 04:50 PM
Last Post: menator01
  Convert string to path using Python 2.7 tester_V 10 6,697 Nov-20-2021, 02:20 PM
Last Post: snippsat
  Convert each element of a list to a string for processing tester_V 6 5,536 Jun-16-2021, 02:11 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020