forked from ElvinKim/2018_1_ITA_python_class_C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20180123_1.py
53 lines (37 loc) · 1.02 KB
/
20180123_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
a = "ABCABCABCCCC"
# count
print("{:-^20}".format(" count "))
print(a.count("AB"))
# index & find
print("{:-^20}".format(" index & find "))
print(a.index("B"))
print(a.find("B"))
# print(a.index("E"))
# print(a.find("E"))
# join
print("{:-^20}".format(" join "))
print(",".join(a))
print("-".join(a))
# upper & lower
print("{:-^20}".format(" upper & lower "))
b = "abcDEFg"
print(b.upper())
print(b.lower())
# strip
print("{:-^20}".format(" strip "))
print(" abc ".lstrip())
print(" abc ".rstrip())
print(" abc ".strip())
# replace
print("{:-^20}".format(" replace "))
print("python is bad".replace("bad", "good"))
print("python is bad bad bad".replace("bad", "good", 2))
# split
print("{:-^20}".format(" split "))
print("python is bad bad bad".split())
print("python,is,bad,bad,bad".split(","))
# format
print("{:-^20}".format(" format "))
print("{:<20}".format("hi"))
print("{:>20}".format("hi"))
print("{:^20}".format("hi"))