Python

[Python]String Function

2017-11-30  本文已影响0人  Chemizi

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']"

上一篇 下一篇

猜你喜欢

热点阅读