-1
我正在Python中开发一个Twitch聊天机器人。但是,我遇到了一些需要很多功能的问题。我需要从JSON文件中提取“gameserverid”和“gameextrainfo”数据。 example file从互联网拉JSON数据并在Python中打印?
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的最新版本上运行(Python的3.5.1)