[Python]String Function

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]String Function)