美文网首页Python
[Python]String Function

[Python]String Function

作者: Chemizi | 来源:发表于2017-11-30 21:06 被阅读0次

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

    本文链接:https://www.haomeiwen.com/subject/ehubbxtx.html