It provides with several string operation functions.
k3fmt is a component of pykit3 project: a python3 toolkit set.
k3fmt
It provides with several string operation functions.
This library is considered production ready.
pip install k3fmt
import k3fmt
lines = [
'hello',
'world',
]
# add left padding to each line in a string
k3fmt.line_pad('\n'.join(lines), ' ' * 4)
# " hello"
# " world"
# format a multi-row line
items = ['name:',
['John',
'j is my nick'
],
'age:',
26,
'experience:',
['2000 THU',
'2006 sina',
'2010 other'
],
]
k3fmt.format_line(items, sep=' | ', aligns='llllll')
# outputs:
# name: | John | age: | 26 | experience: | 2000 THU
# | j is my nick | | | | 2006 sina
# | | | | | 2010 other
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com