Python函数如何返回字符串

  • Python函数如何返回字符串已关闭评论
  • A+
所属分类:技术教程
摘要

使用Python函数返回字符串的方法1.lower()函数返回字符串 a = “Hello, World!”print(a.lower())输出结果为:Hello, World!2.使用upper()返回字符串a = “Hello, Wor

本文收集自网络,
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!

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin