FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonTutor/strings.py at master · johnnyGogo/pythonTutor · GitHub
johnnyGogo
/
pythonTutor
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonTutor
/
strings.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
90 lines (58 loc) · 1.35 KB
Breadcrumbs
pythonTutor
/
strings.py
Copy path
File metadata and controls
90 lines (58 loc) · 1.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
"""
#轉義:
\t
\n
...
#Slice: [start : end : step]
#長度 len()
#分割 split()
#連結 join()
#取代 replace() : str.replace({old}, {new}, {次數}[max])
#尋找第一個位移 str.find({word})
#字首是不是 str.startswith({word})
#字尾是不是 str.endswith({word})
#最後一次位移 str.rfind({word})
#字母出現在幾次 str.count({word})
#是不是只有字母與數字 str.isalnum()
# str.capitalize()
# str.title()
# str.upper()
# str.lower()
# str.swapcase()
# str.center({int})
# str.ljust({int})
# str.rjust({int})
"""
import
fire
def
common_use
():
#轉義
print
(
'轉義:'
)
print
(
'a
\t
b'
)
print
(
'a
\n
b'
)
#slice
# [start : end : step]
print
(
'Slice:'
)
s
=
'abcdefghijklmnopqrstuvwxyz'
print
(
s
[:])
print
(
s
[::
-
1
])
#len
print
(
'
\n
len():'
)
print
(
"{} len:{}"
.
format
(
s
,
len
(
s
)))
#split
print
(
'
\n
split()'
)
s
=
'"a,b,c,d,e"'
print
(
'{}.split(",") : {}'
.
format
(
s
,
s
.
split
(
','
) ))
#join
print
(
'
\n
join()'
)
a
=
[
'a'
,
'b'
,
'c'
]
print
(
'{}.join(",") : {}'
.
format
(
a
,
","
.
join
(
a
)))
#replace
print
(
'
\n
str.replace({old}, {new}, [次數])'
)
s
=
'this is a dog'
print
(
'{}.replace("is" , "", 2) : {}'
.
format
(
s
,
str_array
))
def
capitalize
():
print
(
'this is a test text'
.
capitalize
())
def
title
():
print
(
'this is a test text'
.
title
())
if
__name__
==
'__main__'
:
fire
.
Fire
()
import
doctest
doctest
.
testmod
()
Back
|
FazBrowse Home
|
New Git URL