Files
RustPython/extra_tests/snippets/stdlib_string.py
2025-12-12 22:46:39 +09:00

27 lines
877 B
Python

import string
assert string.ascii_letters == "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
assert string.ascii_lowercase == "abcdefghijklmnopqrstuvwxyz"
assert string.ascii_uppercase == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
assert string.digits == "0123456789"
assert string.hexdigits == "0123456789abcdefABCDEF"
assert string.octdigits == "01234567"
assert string.punctuation == "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
assert string.whitespace == " \t\n\r\x0b\x0c", string.whitespace
assert (
string.printable
== "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c"
)
assert string.capwords("bla bla", " ") == "Bla Bla"
from string import Template
s = Template("$who likes $what")
r = s.substitute(who="tim", what="kung pow")
assert r == "tim likes kung pow"
from string import Formatter
f = Formatter()