Python 谷歌DLP:“;ValueError:协议消息值没有“0”;stringValue“;字段。”;
我有一个方法,我为谷歌的DLP建立了一个多个项目的表,它可以取a,也可以取a 以下是请求的构造方式:Python 谷歌DLP:“;ValueError:协议消息值没有“0”;stringValue“;字段。”;,python,google-cloud-platform,google-cloud-dlp,Python,Google Cloud Platform,Google Cloud Dlp,我有一个方法,我为谷歌的DLP建立了一个多个项目的表,它可以取a,也可以取a 以下是请求的构造方式: def redact_text(text_list): dlp = google.cloud.dlp.DlpServiceClient() project = 'my-project' parent = dlp.project_path(project) items = build_item_table(text_list) info_types = [
def redact_text(text_list):
dlp = google.cloud.dlp.DlpServiceClient()
project = 'my-project'
parent = dlp.project_path(project)
items = build_item_table(text_list)
info_types = [{'name': 'EMAIL_ADDRESS'}, {'name': 'PHONE_NUMBER'}]
inspect_config = {
'min_likelihood': "LIKELIHOOD_UNSPECIFIED",
'include_quote': True,
'info_types': info_types
}
response = dlp.inspect_content(parent, inspect_config, items)
return response
def build_item_table(text_list):
rows = []
for item in text_list:
row = {"values": [{"stringValue": item}]}
rows.append(row)
table = {"table": {"headers": [{"name": "something"}], "rows": rows}}
return table
当我运行此命令时,我返回错误ValueError:Protocol消息值没有“stringValue”字段。
即使和表示相反
我构建请求的方式是否有问题
编辑:这是build\u item\u表的输出
{
'table':
{
'headers':
[
{'name': 'value'}
],
'rows':
[
{
'values':
[
{
'stringValue': 'My name is Jenny and my number is (555) 867-5309, you can also email me at anemail@gmail.com, another email you can reach me at is email@email.com. '
}
]
},
{
'values':
[
{
'stringValue': 'Jimbob Doe (555) 111-1233, that one place down the road some_email@yahoo.com'
}
]
}
]
}
}
请尝试字符串\u值。。。。python使用字段名,而不是类型名