我試圖擺脫價值名稱在迴應。請看下圖:Python刪除或更換密鑰
response_data_all_details = decode_transaction_response(response.text)
# Remove and sensitive information we don't want to be stored in the database.
response_data = remove_sensitive(response_data_all_details)
功能:如果響應有名稱以「未存儲」的文本替換它。
def remove_sensitive(data):
for key in data:
if data[key] == "Name":
data['Name'] = "Not Stored!"
return data
但是,此功能似乎不起作用,爲什麼?
樣品RESPONSE_DATA
{
"URL" : "http:\/\/www.test.com",
"Name" : "James",
"Currency" : "GBP",
"Amount" : 5.880000000000001,
}