2024-09-20 18:01:48 +08:00

43 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
def contains_number_or_index(key, value):
return (isinstance(value, (int, float)) or
(isinstance(value, str) and value.isdigit()) or
'序号' in key or
(isinstance(value, str) and re.search(r'\d+', value)))
def preprocess_dict(data):
if isinstance(data, dict):
if len(data) > 1:
# 检查是否所有值都是 "" 或 "/"
if all(v == "" or v == "/" for v in data.values()):
return list(data.keys())
else:
processed = {}
for k, v in data.items():
if not contains_number_or_index(k, v):
processed_v = preprocess_dict(v)
# 即使 processed_v 是空字符串,也保留键
processed[k] = processed_v
return processed
else:
return {k: preprocess_dict(v) for k, v in data.items()}
elif isinstance(data, list):
return [preprocess_dict(item) for item in data]
else:
return data
input_data = {
"具备法律、行政法规规定的其他条件的证明材料": {
"国家对生产和销售相关产品或提供相关服务有专门法律、行政法规规定的": "则 必须提供取得国家有关主管部门行政许可的证明材料",
"未被列入“信用中国”网站(www.creditchina.gov.cn)信用服务栏失信被执行人、 重大税收违法案件当事人名单、政府采购严重违法失信行为记录名单和“中国 政府采购”网站www.ccgp.gov.cn政府采购严重违法失信行为记录名单": "并 提供网页截图以证明",
"招标文件第一章“投标人资格要求”中有特殊要求的": "投标人应提供其符合特 殊要求的证明材料或者情况说明",
"不符合联合体投标相关规定和要求的": "",
"投标人认为需提供的其它相关资格证明材料": "",
"资格证明文件正本应为清晰彩色影印件且加盖单位公章": ""
}
}
processed_data = preprocess_dict(input_data)
print(processed_data)