check exists when save data

This commit is contained in:
rtz19970824 2017-12-27 19:54:36 +08:00
parent 9f60984973
commit f2291efc72

View File

@ -178,6 +178,9 @@ if __name__ == '__main__':
player[1].run_cmd(str(num) + ' clear_board') player[1].run_cmd(str(num) + ' clear_board')
file_list = os.listdir(args.data_path) file_list = os.listdir(args.data_path)
current_time = strftime("%Y%m%d_%H%M%S", gmtime()) current_time = strftime("%Y%m%d_%H%M%S", gmtime())
if os.path.exists(args.data_path + current_time + ".pkl"):
time.sleep(1)
current_time = strftime("%Y%m%d_%H%M%S", gmtime())
with open(args.data_path + current_time + ".pkl", "wb") as file: with open(args.data_path + current_time + ".pkl", "wb") as file:
picklestring = cPickle.dump(data, file) picklestring = cPickle.dump(data, file)
data.reset() data.reset()