问题
How do I pass json file as an argument in boto3?
import boto3
client = boto3.client('route53')
doc = open('policy.json', 'rb').read()
response = client.create_traffic_policy(
Name = 'test2',
Document = '?????',
Comment = 'new traffic policy'
)
I want to pass a json file in the place of Document
回答1:
you can use the JSON library
import boto3
import json
client = boto3.client('route53')
doc = json.loads(open('cp.json', 'rb').read())
response = client.create_traffic_policy(
Name = 'test2',
Document = json.dumps(doc),
Comment = 'new traffic policy'
)
来源:https://stackoverflow.com/questions/49375885/how-do-i-pass-json-file-in-boto3