길/Python

String Functions

7he8oy 2021. 2. 11. 20:40
print(", ".join(["spam", "eggs", "ham"]))
#prints "spam, eggs, ham"

print("Hello ME".replace("ME", "world"))
#prints "Hello world"

print("This is a sentence.".startswith("This"))
# prints "True"

print("This is a sentence.".endswith("sentence."))
# prints "True"

print("This is a sentence.".upper())
# prints "THIS IS A SENTENCE."

print("AN ALL CAPS SENTENCE".lower())
#prints "an all caps sentence"

print("spam, eggs, ham".split(", "))
#prints "['spam', 'eggs', 'ham']"

 

' > Python' 카테고리의 다른 글

Generators  (0) 2021.02.12
List Functions  (0) 2021.02.11
dic.get(key [,default])  (0) 2021.02.11
try / except / finally / assert  (0) 2021.02.11
List Functions  (0) 2021.02.10