如何从AWS中打印出Boto EC2输出?
这是原作(不太漂亮):
{u'预订':[{u' OwnerId':' 123456789012',u' ReservationId': ' r-0583ea9691fc65d99',u'群组':[],u'实例':[{u'监控': {u' State':'禁用'},u' PublicDnsName': ' ec2-52-91-153-194.compute-1.amazonaws.com',你'陈述':{u'代码':16, 你的名字':'运行'},你' EbsOptimized':False,u' LaunchTime': datetime.datetime(2017,4,11,14,2,13,tzinfo = tzutc()), u' PublicIpAddress':' 52.91.153.194',u' PrivateIpAddress':' 10.0.0.50', 你' ProductCodes':[],你' VpcId':' vpc-f06bb096', 你是StateTransitionReason':'',u' InstanceId':' i-00b54d7f43d6d6c41', 你' ImageId':' ami-f4cc1de2',你' PrivateDnsName': ' ip-10-0-0-50.ec2.internal',u' KeyName':' ec2-test', u' SecurityGroups':[{u' GroupName':'默认',u' GroupId': ' sg-d91a11a4'}],u' ClientToken':'',u' SubnetId':' subnet-983e31a4' , 你的实例类型':' t2.micro',u' NetworkInterfaces':[{u'状态': '正在使用',' MacAddress':#06; 25:23:48:95:a6',u' SourceDestCheck': 是的,你' VpcId'' vpc-f06bb096','说明':'','关联': {u' PublicIp':' 52.91.153.194',u' PublicDnsName': ' ec2-52-91-153-194.compute-1.amazonaws.com',u' IpOwnerId':' amazon'}, 你' NetworkInterfaceId':' eni-7813e976',你' PrivateIpAddresses': [{u' PrivateDnsName':' ip-10-0-0-50.ec2.internal',u' Association': {u' PublicIp':' 52.91.153.194',u' PublicDnsName': ' ec2-52-91-153-194.compute-1.amazonaws.com',u' IpOwnerId':' amazon'}, 你小学':是的,你的私人地理位置':' 10.0.0.50'}], 你好私人姓名':' ip-10-0-0-50.ec2.internal',你'依恋': {u' Status':' attach',u' DeviceIndex':0,u' DeleteOnTermination': 是的,你' AttachmentId'' eni-attach-1497b932',u' AttachTime': datetime.datetime(2017,4,13,14,13,tzinfo = tzutc())},u'群组': [{u' GroupName':'默认',u' GroupId':' sg-d91a11a4'}],u' SubnetId' : ' subnet-983e31a4',u' OwnerId':' 123456789012',u' PrivateIpAddress': ' 10.0.0.50'}],你' SourceDestCheck':是的,你'安置':{u'租约': '默认',u' GroupName':'',u' AvailabilityZone':' us-east-1a'}, 你的管理程序':' xen',u' BlockDeviceMappings':[{u' DeviceName': ' / dev / sda1',你' Ebs':{u'状态':'附加',u' DeleteOnTermination': 是的,你' VolumeId'' vol-0bde7c66b5d2bfbe3',u' AttachTime': datetime.datetime(2017,4,13,14,2,14,tzinfo = tzutc())}}], u'架构':' x86_64',u' RootDeviceType':' ebs', u' RootDeviceName':' / dev / sda1',u' VirtualizationType':' hvm', 你' AmiLaunchIndex':0}]},{u' OwnerId':' 123456789012', 你' ReservationId':' r-045b809e272d93e2b',你'群组':[],你'实例': [{u'监控':{u'州':'禁用'},u' PublicDnsName':'', 你的RootDeviceType':' ebs',你'陈述':{u'代码':48,你'姓名': '终止'},你被EbsOptimized':False,你' LaunchTime': datetime.datetime(2017,4,13,12,56,12,tzinfo = tzutc()), 你的产品代码':[],你' StateTransitionReason':'用户发起的 (2017-04-13 13:57:36 GMT)',u' InstanceId':' i-0c474bd415597945d', 你想象一下' ami-f4cc1de2',你' PrivateDnsName':'',你' KeyName': ' ec2-test',u' SecurityGroups':[],u' ClientToken':'', 你' InstanceType':' t&2;',' NetworkInterfaces':[],u'展示位置': {u'租约':'默认',您' GroupName':'',u' AvailabilityZone': ' us-east-1a'},u' Hypervisor':' xen',u' BlockDeviceMappings':[], 你'建筑':' x86_64',你' StateReason':{u'消息': ' Client.UserInitiatedShutdown:用户启动关机',u'代码': ' Client.UserInitiatedShutdown'},u' RootDeviceName':' / dev / sda1', u' VirtualizationType':' hvm',u' AmiLaunchIndex':1},{u'监控': {u'州':'已禁用'},u' PublicDnsName':'',u' RootDeviceType': ' ebs','陈述':{u'代码':48,你'姓名':'终止'}, 你被EbsOptimized':False,你' LaunchTime':datetime.datetime(2017年,4,13, 12,56,12,tzinfo = tzutc()),u' ProductCodes':[], u' StateTransitionReason':'用户发起(2017-04-13 13:57:36 GMT)', 你的实例':' i-08a8961ce06801f38',你' ImageId':' ami-f4cc1de2', 你的私人目的地':'',你' KeyName':' ec2-test',u' SecurityGroups':[], u' ClientToken':'',u' InstanceType':' t2.micro',u' NetworkInterfaces': [],u'展示位置':{u'租赁':'默认',u' GroupName':'', 你可以使用':' us-east-1a'},u'管理程序':' xen', 你和BlockDeviceMappings':[],你'架构':' x86_64',你' StateReason': {u'消息':' Client.UserInitiatedShutdown:用户启动关机', 你的代码':' Client.UserInitiatedShutdown'},u' RootDeviceName': ' / dev / sda1',u' VirtualizationType':' hvm',u' AmiLaunchIndex':2}, {u'监控':{u'州':'禁用'},u' PublicDnsName':'', 你的RootDeviceType':' ebs',你'陈述':{u'代码':48,你'姓名': '终止'},你被EbsOptimized':False,你' LaunchTime': datetime.datetime(2017,4,13,12,56,12,tzinfo = tzutc()), 你的产品代码':[],你' StateTransitionReason':'用户发起的 (2017-04-13 13:57:36 GMT)',u' InstanceId':' i-0912694d25b7c2d4f', 你想象一下' ami-f4cc1de2',你' PrivateDnsName':'',你' KeyName': ' ec2-test',u' SecurityGroups':[],u' ClientToken':'', 你' InstanceType':' t&2;',' NetworkInterfaces':[],u'展示位置': {u'租约':'默认',您' GroupName':'',u' AvailabilityZone': ' us-east-1a'},u' Hypervisor':' xen',u' BlockDeviceMappings':[], 你'建筑':' x86_64',你' StateReason':{u'消息': ' Client.UserInitiatedShutdown:用户启动关机',u'代码': ' Client.UserInitiatedShutdown'},u' RootDeviceName':' / dev / sda1', u' VirtualizationType':' hvm',u' AmiLaunchIndex':0}]}], ' ResponseMetadata':{' RetryAttempts':0,' HTTPStatusCode':200, ' RequestId'' f698802c-3506-49f5-8bc6-d40639e1e12c',' HTTPHeaders': {' transfer-encoding':' chunked','':' Accept-Encoding',' server': ' AmazonEC2','内容类型':' text / xml; charset = UTF-8',' date':'周四, 2017年4月13日14:04:51 GMT'}}}
那些u
是什么?
如果我尝试使用Python的JSON转储,我会得到:
TypeError: datetime.datetime(2017, 4, 13, 14, 2, 13, tzinfo=tzutc()) is not JSON serializable
答案 0 :(得分:3)