1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/diyanqi07-TastickOJ

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
problem_set.py 840
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
diyanqi Отправлено 13.08.2020 06:49 585e316
import json
import os
def read_file_as_str(file_path):
# 判断路径文件存在
if not os.path.isfile(file_path):
raise TypeError(file_path + " does not exist")
all_the_text = open(file_path).read()
# print type(all_the_text)
return all_the_text
def user_post(user,problem_id,chengji):
data=json.loads(read_file_as_str('users.json'))
try:
if data[user][str(problem_id)]==100:
return True
except:
pro_data=json.loads(read_file_as_str('html/problem/topics/'+str(problem_id)+'.json'))
data[user]['problems'][str(problem_id)]=chengji
with open('html/problem/topics/'+str(problem_id)+'.json',"w") as file:
file.write(json.dumps(pro_data))
with open('users.json',"w") as file:
file.write(json.dumps(data))
return False

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/diyanqi07-TastickOJ.git
git@api.gitlife.ru:oschina-mirror/diyanqi07-TastickOJ.git
oschina-mirror
diyanqi07-TastickOJ
diyanqi07-TastickOJ
master