Closed 1chooo closed 1 month ago
https://github.com/TODAM-tw/todam-ticket-system/blob/7e6abfd17bcadfffbe36aad53846b5b20f41e98c/app/cases/segment.py#L36
這樣會導致
print(str(segment_id_name_map)) ^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not callable
可以用 json.dumps() 的方式轉換 JSON type 的 str
json.dumps()
JSON
str
segment_id_name_map = {segment["segment_id"]: segment["segment_name"] for segment in data["segments"]} segment_id_name_map_str = json.dumps(segment_id_name_map, ensure_ascii=False, indent=4)
需要研究為什麼不能直接用 str() 來轉換
str()
https://github.com/TODAM-tw/todam-ticket-system/blob/7e6abfd17bcadfffbe36aad53846b5b20f41e98c/app/cases/segment.py#L36
這樣會導致
可以用
json.dumps()
的方式轉換JSON
type 的str