mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
11 lines
395 B
Python
11 lines
395 B
Python
def set_value_for_key(data, target_key, new_value):
|
|
if isinstance(data, dict):
|
|
for key, value in data.items():
|
|
if key == target_key:
|
|
data[key] = new_value
|
|
else:
|
|
set_value_for_key(value, target_key, new_value)
|
|
elif isinstance(data, list):
|
|
for item in data:
|
|
set_value_for_key(item, target_key, new_value)
|