我有这个密码:
if 'instagramTV' in path:
self.send_response(200)
instaShortcode, LTV, EMAIL, TIME, userID, URL = map(\
qs.get, ['instaID', 'channelID', 'uEmail', 'Time', 'uID', 'contentUrl'])
channelID, uEmail, instagramShortcode, uTime, uID, contentUrl = map(\
lambda x : str(x)[2:-2], [LTV, EMAIL, instaShortcode, TIME, userID, URL])
for i in (channelID, uEmail, instagramShortcode, uTime, uID, contentUrl):
print i
instaSTEP2 = requests.get("http://api.instagram.com/oembed?url=http://instagr.am/p/%s/"% instagramShortcode).json()
instaMeID = instaSTEP2['media_id']
instaINFO = requests.get("https://api.instagram.com/v1/media/%s?accesstoken=295391286.1b882b8.33fa51373fae4885b5c60ceb186e6560" % instaMeID).json()
print instaINFO['data']['user']['profile_picture']
print instaINFO['data']['user']['username']
print instaINFO['data']['caption']['text']
print instaINFO['data']['images']['standard_resolution']['url']
ltvMSG = {'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'timeSENT': 'uTime', 'profiePIC': "instaINFO['data']['user']['profile_picture']",'userNAME': "instaINFO['data']['user']['username']", 'msgBODY': "instaINFO['data']['caption']['text']", 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']"}
print ltvMSG
首先,变量来自httpget请求,然后我使用其中的一些变量进行api调用,然后返回一些json。你知道吗
我试图将get请求中的一些初始变量和api调用中的一些值放入我自己的dict/json中,最终将放入redis列表中。你知道吗
print ltvMSG返回:
{'userNAME': "instaINFO['data']['user']['username']", 'timeSENT': 'uTime', 'msgIMAGE': "instaINFO['data']['images']['standard_resolution']['url']", 'msgBODY': "instaINFO['data']['caption']['text']", 'fromEMAIL': 'uEmail', 'toCHANNELID': 'channelID', 'profilePIC': "instaINFO['data']['user']['profile_picture']"}
这是我想要的结构,但如何使实际值显示为键的值。你知道吗
您要做的是将这些字符串文字添加到dict中。因此,如果,而不是:
您需要:
例如,它将存储
uEmail
的值,而不是字符串'uEmail'
。你知道吗相关问题 更多 >
编程相关推荐