print("----------字符串拼接--------------")
a = "hello"
b = "python"
print(f"{a} {b}") # f字符串
print(a + " " + b)
print("-----------输出首字母大写的单词(名字)------")
name = "ada"
name2 = "ADA"
name3 = "aDA"
name4 = "Ada"
print(name.title())
print(name2.title())
print(name3.title())
print(name4.title()) # 首字母转为大写,其余都是小写
print(name3.upper()) # 全部转大写
print(name4.lower()) # 全部转小写
print("------------strip()删除首尾的空白-----------------------")
# rstrip()剔除尾部空白,lstrip()剔除开头的空白
fav = " python "
fav = fav.strip()
fa1 = "hello"
print(f"{fav}{fa1}")
print("------数中的下划线-------------")
# 下划线方便读数,不会显示
numb = 13_0000
print(numb)
python的基础语法01
最新推荐文章于 2024-11-14 13:48:50 发布