标签: Python函数如何返回字符串

  • Python函数如何返回字符串_读书小站

    本文收集自网络,侵删!

    Python函数如何返回字符串

    使用python函数返回字符串的方法

    lower()函数返回字符串

    a = "Hello, World!"

    print(a.lower())

    输出结果为:

    Hello, World!

    使用upper()返回字符串

    a = "Hello, World!"

    print(a.upper())

    输出结果为:

    HELLO, WORLD!

    使用replace()函数返回字符串

    txt = "hello world!"

    x = txt.replace("hello", "hi")

    print(x)

    输出结果为:

    hi world!