Skip to content

Commit 47aeb52

Browse files
committed
examples
1 parent 644b293 commit 47aeb52

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

examples/printer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from string_py import Printer
2+
3+
print = Printer()
4+
5+
print.time("Hello World!")
6+
print.slow("Hello World!")
7+
# Changes only visible in console

examples/string_formatting.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from string_py import Format
2+
3+
print(Format.align(values={"Username:": "John", "Register Date:": "01.01.2001"}))
4+
# Output:
5+
6+
# Username: John
7+
# Register Date: 01.01.2001

examples/string_manipulation.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from string_py import Str
2+
import string
3+
4+
# Generate
5+
print(Str("".join(string.ascii_lowercase + string.ascii_uppercase + string.digits)).generate(length=10))
6+
# Output Example: 741P4MBHc5
7+
8+
# Split
9+
print(Str("Hello World!").split(each=3))
10+
# Output: ['Hel', 'lo ', 'Wor', 'ld!']
11+
print(Str("Hello World!").split(chars=" "))
12+
# Output: ['Hello', 'World!']
13+
14+
# First and Last
15+
print(Str("Hello World!").first())
16+
# Output: H
17+
print(Str("Hello World!").first(5))
18+
# Output: Hello
19+
print(Str("Hello World!").first(5, remove=True))
20+
# Output: World!
21+
print(Str("Hello World!").last())
22+
# Output: !
23+
print(Str("Hello World!").last(5))
24+
# Output: World!
25+
print(Str("Hello World!").last(5, remove=True))
26+
# Output: Hello

0 commit comments

Comments
 (0)