python - Python推文分析
问题描述
我在 Python 中有以下代码:
from datetime import date
from datetime import timedelta
def tweets_user_student(user):
search_params = { 'screen_name': user,'result_type': 'recent', 'count': 1}
search_url = '{}1.1/statuses/user_timeline.json'.format(base_url)
search_resp = requests.get(search_url, headers=search_headers, params=search_params)
Data = json.loads( search_resp.content.decode("utf-8") )
for tweet in Data:
<GAP_1>
if <GAP_2>:
tweets_user_student = {tweet['user']['screen_name']: tweet['user']['followers_count']}
dict_tweets_student.update(tweets_user_student)
print(tweets_user_student)
list_users_student=[<GAP3>]
dict_tweets_student={}
for user in list_users_student:
tweets_user_student(user)
print(dict_tweets_student)
我需要为每个用户显示分析上周推文的关注者数量。
我显示了上周发布的两个用户的推文数量。为此,我可以使用 datetime 模块以及 date 和 timedelta 对象,但我不知道该怎么做。有人可以帮助我吗?我该如何填补这些空白?
谢谢!
解决方案
推荐阅读
- javascript - 将外部 JavaScript / CSS 甚至图像包含到 html 中
- c++ - 无法理解此 c++ 代码中的问题
- java - 摆动全屏快捷方式
- sql - 如何设置此图表?(多种销售方式)
- python - 连接到 docker postgres 时启动数据包的长度无效
- html - 如果表存在 Bootstrap,导航栏下拉菜单将不起作用
- go - 将混合了数字和字母的字符串转换为数字
- java - Spring Boot - 如何创建不同 JpaRepository 接口的工厂
- excel - OBIEE 11 - 如何在没有提示的情况下在 excel 中导出多页仪表板
- regex - 如何从文件中获取一个值并忽略注释行?