---
title: "Yaml与python类型的对照表"
author: "huangro"
date: "2009-04-22T23:03:15Z"
tags: ["F#", "Python"]
slug: "yaml-python"
draft: false
lastmod: "2009-04-22T23:03:15Z"
id: 372976
url: "https://huangro.iteye.com/blog/372976"
---

因为常用yaml作为python程序的配置文件，特将其与python类型参照表在此贴出，以供温故之用。

 

 

**YAML tag**

**Python type**

*Standard YAML tags*

 

`!!null`

`None`

`!!bool`

`bool`

`!!int`

`int`

`!!float`

`float`

`!!binary`

`str`

`!!timestamp`

`datetime.datetime`

`!!omap`

!!pairs `list`of pairs

`!!set`

`set`

`!!str`

`str`

`!!seq`

`list`

`!!map`

`dict`

*Python-specific tags*

 

`!!python/none`

`None`

`!!python/bool`

`bool`

`!!python/str`

`str`

`!!python/unicode`

`unicode`

`!!python/int`

`int`

`!!python/long`

`long`

`!!python/float`

`float`

`!!python/complex`

`complex`

`!!python/list`

`list`

`!!python/tuple`

`tuple`

`!!python/dict`

`dict`

*Complex Python tags*

 

`!!python/name:module.name`

`module.name`

`!!python/module:package.module`

`package.module`

`!!python/object:module.cls`

`module.cls`

`!!python/object/new:module.cls`

`module.cls`

`!!python/object/apply:module.f`

value