跳转到主要内容

将旧式的 %-style 格式字符串转换为新的 {}-style

项目描述

https://travis-ci.org/moreati/formatist.svg?branch=master

一个Python库,用于将旧式的 % 样式格式字符串转换为新的 {} 样式。

>>> import formatist
>>> greeting = "Hello %(name)s. It's %(temp).1f C"
>>> print(greeting % {'name': 'Alice', 'temp': 23.45678})
Hello Alice. It's 23.5 C
>>> greeting2 = formatist.convert(greeting)
>>> print(greeting2)
Hello {name!s:}. It's {temp:>.1f} C
>>> print(greeting2.format(name='Alice', temp=23.45678))
Hello Alice. It's 23.5 C

项目详情


下载文件

下载适合您平台的应用程序文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分布

formatist-0.0.2.tar.gz (2.1 kB 查看哈希值)

上传时间: 源代码

构建分布

formatist-0.0.2-py2.py3-none-any.whl (6.3 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下支持