- 变量和简单数据类型
print(message)
# 变量的使用规则
# 只能包含数字 字母 下划线 且开头不能够是数字 ,变量名不能够包含空格,不可以是关键字和函数名
- 字符串
# 字符串
# 用单引号或者是双引号包括起来的就是字符串 使用比较灵活
test='this is a string'
test2="this is a String"
test3="this is 'a' String"
test4='this is "a" String'
print(test+'\n'+test2+'\n'+test3+'\n'+test4)
# 字符串函数
test5='naMe aBc'
print(test5.title()) #将字符串的单词的第一个字母大写,其他小写
print(test5.upper())
print(test5.lower())
# 合并字符串
firstName= 'xiao'
lastName= 'Li'
print(firstName+" "+lastName)
# 去掉字符串的空白
test6=' Python '
print(test6.rstrip()) #去掉右端也就是尾部的空格
print(test6.lstrip()) #去掉左端也就是尾部的空格
print(test6.strip()) #去掉两段的空格
- 整数
# 整数
# 加减乘除
print(2+3)
print(3-2)
print(3*2)
print(3/2)
print(3**3) #乘方是用两个* 表示
# 在字符串和整数一起使用时候要用str() 函数转换类型
age=20
print("my age is "+str(age))