【发布时间】:2021-01-12 10:38:15
【问题描述】:
我想使用 requests 库和 discord.py 库从 cheat.sh 中获取数据....但是由于 discord 一次只允许发送 2000 个字符,所以我只想获取一定数量的像 1800 这样的单词/数字/换行符。我该怎么做?
一小段代码示例展示了我的想法
import requests
url = "https://cheat.sh/python/string+annotations" #this gets the docs of string annotation in python
response = requests.get(url)
data = response.text # This gives approximately 2403 words...but i want to get only 1809 words
print(data)
【问题讨论】:
-
使用
response.text[:1800]获取response.text中的前1800或更少
标签: python-3.x python-requests urllib discord.py-rewrite