k3fmt
It provides with several string operation functions.
k3fmt is a component of pykit3 project: a python3 toolkit set.
Name
k3fmt
It provides with several string operation functions.
Status
This library is considered production ready.
Install
pip install k3fmt
Synopsis
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
# ['ab']
print(k3fmt.tokenize("ab"))
# ['a', 'b']
print(k3fmt.tokenize("a b"))
# ['a', 'b']
print(k3fmt.tokenize(" a b "))
# ['a', 'b']
print(k3fmt.tokenize(" a\t b\n c\r "))
# ['a b', 'c d']
print(k3fmt.tokenize("a bxyc d", sep="xy"))
# ['a', 'x x', 'b']
print(k3fmt.tokenize('a "x x" b'))
# ['a', 'x x', 'b']
print(k3fmt.tokenize("a 'x x' b 'x")) # the last `'x` has no pair, discard
# ['a', 'a b', 'c d']
print(k3fmt.tokenize(" a xa bx yc dy ", quote="xy"))
# ['a', 'xa bx', 'yc dy']
print(k3fmt.tokenize("a xa bx yc dy", quote="xy", preserve=True))
# ['', 'a', 'xa bx', 'yc dy', '']
print(k3fmt.tokenize(" a xa bx yc dy ", sep=" ", quote="xy", preserve=True))
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3fmt 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| k3fmt-0.1.8.tar.gz | 12.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| k3fmt-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / k3fmt-0.1.8.tar.gz
| Download URL | k3fmt-0.1.8.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86124bd7ce60163f98090fbf400cb1f2c88255529ac71bc48723939fbf0c91a3
|
|
BLAKE2b-256 checksum How to use checksums |
1623cdbd17a07ee1525b90b6aebf3e62c2d488e7ae1d4cf07151500240bd8bf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / k3fmt-0.1.8-py3-none-any.whl
| Download URL | k3fmt-0.1.8-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
218283c6fff79303f6f46a79c75c827dce7871b358ef1e585df974c661385a09
|
|
BLAKE2b-256 checksum How to use checksums |
2ba3be05ba62566ead1f2e1963f59733affb9317e2de84f67c9546aa949b7934
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|