1.字符串函数
name = "james jacKSON"
name.title() # 字符串首字母大写,其余字母变小写
name.upper()
name.lower()
2.在字符串中使用变量 - f字符串 (Python3.6引入的)
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(full_name)
print(f"Hello, {full_name.title()}")
message = f"Hello, {full_name.title()}"
print(message)
3.制表符和换行符来添加空白
print("Language:\n\tPython\n\tC\n\tJavaScript")
4.删除空白
# 末尾去掉空格
favorite_language.rstrip()
# 开头去掉空格
favorite_language.lstrip()
# 两头去掉空格
favorite_language.strip()
标签:full,name,language,title,python,print,字符串
From: https://www.cnblogs.com/route/p/17529546.html