함수 pprint()

1 개요[ | ]

pprint


2 Go[ | ]

package main

import (
	"encoding/json"
	"fmt"
)

func dump(o interface{}) {
	b, _ := json.MarshalIndent(o, "", "  ")
	fmt.Print(string(b))
}

func main() {
	orders := []interface{}{
		map[string]interface{}{"id": 1, "name": "Ashley", "date": "2020-05-20"},
		map[string]interface{}{"id": 2, "name": "Peter", "date": "2020-05-20"},
		map[string]interface{}{"id": 3, "name": "Ashley", "date": "2020-05-05"},
		map[string]interface{}{"id": 4, "name": "John", "date": "2020-05-05"},
		map[string]interface{}{"id": 5, "name": "Peter", "date": "2020-05-05"},
	}
	dump(orders)
}
package main

import (
	"fmt"

	"github.com/go-yaml/yaml"
)

func dump(o interface{}) {
	d, _ := yaml.Marshal(o)
	fmt.Print(string(d))
}

func main() {
	orders := []interface{}{
		map[string]interface{}{"id": 1, "name": "Ashley", "date": "2020-05-20"},
		map[string]interface{}{"id": 2, "name": "Peter", "date": "2020-05-20"},
		map[string]interface{}{"id": 3, "name": "Ashley", "date": "2020-05-05"},
		map[string]interface{}{"id": 4, "name": "John", "date": "2020-05-05"},
		map[string]interface{}{"id": 5, "name": "Peter", "date": "2020-05-05"},
	}
	dump(orders)
}

3 Python[ | ]

from pprint import pprint
orders = [
  {'id': 1, 'name': 'Ashley', 'date': '2020-05-20'},
  {'id': 2, 'name': 'Peter' , 'date': '2020-05-20'},
  {'id': 3, 'name': 'Ashley', 'date': '2020-05-05'},
  {'id': 4, 'name': 'John'  , 'date': '2020-05-05'},
  {'id': 5, 'name': 'Peter' , 'date': '2020-05-05'},
]
pprint( orders )

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}