【发布时间】:2016-02-28 15:58:50
【问题描述】:
我有以下代码,
def main():
SucessCount = 0
line = []
StringList = ''
url = "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key=&match_id=1957663499"
http = urllib3.PoolManager()
for i in range(1860878309, 1860878309 + 99999999999999999 ):
with open("DotaResults.txt", "w") as file:
if SucessCount > 70000:
break
result = http.request('GET', 'https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key=F878695BB3657028B92BCA60CEA03E16&match_id=' + str(i))
x = json.loads(result.data.decode('utf-8'))
if('error' in x['result']):
print("Not found")
else:
if validityCheck(x['result']['players']) == True and x['result']['game_mode'] == 22:
line = vectorList(x)
#print(line.count(1))
if(line.count(1) == 10 or line.count(1) == 11):
SucessCount += 1
print('Ok = ' + str(SucessCount))
print("MatchId = " + str(x['result']['match_id']))
StringList = ','.join([str(i) for i in line])
file.write(StringList + '\n')
if(SucessCount % 5 == 0):
file.flush()
file.close()
time.sleep(30)
我遇到的问题是,当我在 pycharm 中按下停止按钮(在正常运行模式下)时,文件中没有任何显示,即使我每次循环时都关闭文件。有谁知道为什么或我能做些什么来解决这个问题?
【问题讨论】: