Advertisement
Guest User

Untitled

a guest
Aug 4th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. import yaml, json
  2.  
  3. datos = [
  4.     {"densidad": [0.6, 0.7], "humedad": [0.5, 0.7]},
  5.     {"densidad": [0.66, 0.89], "humedad": [0.4, 0.7]},
  6.     {"densidad": [0.61, 0.74], "humedad": [0.1, 0.7]},
  7. ]
  8.  
  9. print json.dumps(datos, indent=4)
  10.  
  11. # salida json
  12. """
  13. [
  14.    {
  15.        "humedad": [
  16.            0.5,
  17.            0.69999999999999996
  18.        ],
  19.        "densidad": [
  20.            0.59999999999999998,
  21.            0.69999999999999996
  22.        ]
  23.    },
  24.    {
  25.        "humedad": [
  26.            0.40000000000000002,
  27.            0.69999999999999996
  28.        ],
  29.        "densidad": [
  30.            0.66000000000000003,
  31.            0.89000000000000001
  32.        ]
  33.    },
  34.    {
  35.        "humedad": [
  36.            0.10000000000000001,
  37.            0.69999999999999996
  38.        ],
  39.        "densidad": [
  40.            0.60999999999999999,
  41.            0.73999999999999999
  42.        ]
  43.    }
  44. ]
  45. """
  46.  
  47.  
  48. print yaml.dump(datos, default_flow_style=False)
  49.  
  50.     # salida yaml
  51.   """  
  52.    - densidad:
  53.      - 0.59999999999999998
  54.      - 0.69999999999999996
  55.      humedad:
  56.      - 0.5
  57.      - 0.69999999999999996
  58.    - densidad:
  59.      - 0.66000000000000003
  60.      - 0.89000000000000001
  61.      humedad:
  62.      - 0.40000000000000002
  63.      - 0.69999999999999996
  64.    - densidad:
  65.      - 0.60999999999999999
  66.      - 0.73999999999999999
  67.      humedad:
  68.      - 0.10000000000000001
  69.      - 0.69999999999999996
  70.    """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement