变量名只能包含字母、数字和下划线。变量名能以字母或下划线开头 不能以数字开头 不能包含空格。
字符串是一系列字符 在python中用引号括起来的就是。
在字符串中使用变量用f
first_name ada
last_name lovelace
full_name f {first_name} {last_name}
print( hello, ,full_name.title())
输出 hello Ada Lovelace
.title()是以首字母大写的方式显示每个单词。.upper()是将字符串全部改为大写。.lower()是将字符串全部改为小写。
.rstrip()是删除后面空白。.lstrip()、.strip()是删除前面空白
favorite_language python 1223 324 print(favorite_language) # print(favorite_language.rsplit()) # print(favorite_language) # favorite_language favorite_language.rsplit() # print(favorite_language) print(favorite_language.strip()) print(favorite_language.lstrip())
运行结果
python 1223 324 python 1223 324 python 1223 324



