我正在用Python开发一个Twitch聊天机器人。然而,我有一些麻烦的功能,已经要求了很多。我需要从JSON文件中提取“gameserverid”和“gameextrainfo”数据。example file
import urllib2
import json
req = urllib2.Request("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=605C90955CFDE6B1CB7D2EFF5FE824A0&steamids=76561198022404556")
opener = urllib2.build_opener()
f = opener.open(req)
json = json.loads(f.read())
currentlyPlaying = json[gameextrainfo]
gameServer = json[gameserverid]
这是我目前掌握的密码。我想得到它,以便其他命令可以打印变量“currentlyPlaying”和“gameServer”到IRC聊天。但是,当我这样做时,我会在控制台中看到:
Traceback (most recent call last):
File "N:/_DEVELOPMENT/Atlassian Cloud/TwitchChatBot/Testing/grabplayerinfofromsteam.py", line 1, in <module>
import urllib2
ImportError: No module named 'urllib2'
有什么想法吗?我在Windows环境中,运行最新版本的Python(python3.5.1)
但是不要使用
urllib2
,使用请求!你知道吗http://docs.python-requests.org/en/master/
相关问题 更多 >
编程相关推荐