我试图用tweepy推文发送两个元素,如:
api.update_status(item, "-Oliver")
然而,当我发推文时,它只发推文" item"而不是" Item -Oliver" 我尝试将它结合起来
total = item, "-Oliver"
api.update_status(total)
但是那条推文看起来像是:(你' Jake Gyllenhaal',' -Oliver')我的代码到目前为止是:
#movie loving bot
import requests
import re
from bs4 import BeautifulSoup as BS
import tweepy
from secrets import *
#create OAuthHandler instance
#Twitter requires all requests to use OAuth for authentification
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
#construct API instance
#entry point for operations performed with twitter
api = tweepy.API(auth) #create an API object
calcAgain = True
while (calcAgain == True):
movie = raw_input("What movie u want? If title more than 1 word seperate with hyphen: ")
crewType = raw_input("What crew person u want: ")
link = "https://letterboxd.com/film/%s/" % (movie)
#requesting page data
page = requests.get(link)
#getting html content from page
soup = BS(page.content, 'html.parser')
easyCrew = ['director', 'actor']
if crewType in easyCrew:
crews = soup.find('a', {'itemprop' : crewType})
crew = crews.find('span', {'itemprop' : 'name'})
for item in crew:
total = item, "-Oliver"
api.update_status(total)
invalidAns2 = True #checks for valid input
while (invalidAns2) == True : #try again loop
exit = raw_input("Anotha one? (y/n)")
if exit == 'y' or exit == 'Y': #play again
invalidAns2 = False
elif exit == 'n' or exit == 'N': #end program
print "Thanks for playing, goodbye!"
invalidAns2 = False
calcAgain = False
else :
print "Please enter y for yes or n for no." #error statement
答案 0 :(得分:2)
update_status()
期望推文的文本(字符串)作为第一个参数,连接字符串:
var post = await db.Posts.Take(10)
.Select(p => new PostViewModel {
Post = p,
Tags = p.Tags.Select(pt => pt.Tag).AsQueryable()
.Select(TagViewModel.Select)
})
.ToArrayAsync();