-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)