You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

read_json.py 423 B

1 year ago
12345678910111213141516171819
  1. import json
  2. import sys
  3. def get_value_from_json(file_path, key):
  4. with open(file_path, 'r') as f:
  5. data = json.load(f)
  6. if key in data:
  7. return data[key]
  8. else:
  9. return None
  10. if __name__ == "__main__":
  11. file_path = sys.argv[1]
  12. key = sys.argv[2]
  13. value = get_value_from_json(file_path, key)
  14. if value is not None:
  15. print(value)
  16. else:
  17. sys.exit(1)

Jittor 2024 Competition Track 2, Rank 24 in A List