我是编码/ python的新手,我正在尝试使用python进行简单的用户检查,但我不知道如何从www.site.com/mytextfile.txt或pastebin.com获取这些文字/原料/ 1111111
我将有多个“用户”,其中一个在新行中
我的代码是这样的:
user = input('Write something')
If user == this is where I want it to check the online txt:
do something
Else:
do other something instead
在线txt将是这样的:
user1
user2
user3
user4
有什么想法吗?
答案 0 :(得分:0)
In [1]: import requests # requests module of python (can be installed via pip)
...: url = 'https://pastebin.com/raw/nkGg7bFy' # url of paste
...: r = requests.get(url) # response will be stored from url
...: content = r.text # raw text from url
...: print(content) # prints content
...:
user1
user2
user3
user4