Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yaml, json
- datos = [
- {"densidad": [0.6, 0.7], "humedad": [0.5, 0.7]},
- {"densidad": [0.66, 0.89], "humedad": [0.4, 0.7]},
- {"densidad": [0.61, 0.74], "humedad": [0.1, 0.7]},
- ]
- print json.dumps(datos, indent=4)
- # salida json
- """
- [
- {
- "humedad": [
- 0.5,
- 0.69999999999999996
- ],
- "densidad": [
- 0.59999999999999998,
- 0.69999999999999996
- ]
- },
- {
- "humedad": [
- 0.40000000000000002,
- 0.69999999999999996
- ],
- "densidad": [
- 0.66000000000000003,
- 0.89000000000000001
- ]
- },
- {
- "humedad": [
- 0.10000000000000001,
- 0.69999999999999996
- ],
- "densidad": [
- 0.60999999999999999,
- 0.73999999999999999
- ]
- }
- ]
- """
- print yaml.dump(datos, default_flow_style=False)
- # salida yaml
- """
- - densidad:
- - 0.59999999999999998
- - 0.69999999999999996
- humedad:
- - 0.5
- - 0.69999999999999996
- - densidad:
- - 0.66000000000000003
- - 0.89000000000000001
- humedad:
- - 0.40000000000000002
- - 0.69999999999999996
- - densidad:
- - 0.60999999999999999
- - 0.73999999999999999
- humedad:
- - 0.10000000000000001
- - 0.69999999999999996
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement