def generateGradeJson(): try: grade_dict={ "grade":[] } grade_list=Grade.get_grades() for i in grade_list: grade_dict["grade"].append(i) with open(__StaticDir__+"grade.json",'w') as f: f.write(json.dumps(grade_dict))#把json格式的内容写入文件 except StandardError,e: #print e raise