一、字符串
1. 在Python中,用引号括起来的都是字符串,如:
#单引号 name = ‘nianhua‘ #双引号 name = "nianhua" #三个单引号 name = ‘‘‘nianhua‘‘‘ #三个双引号 name = """nianhua"""
2. 字符串的简单操作
字符串的加法(拼接)
first_name = ‘abc‘ last_name = ‘cba‘ full_name = first_name+" "+last_name print(full_name)
字符串的乘法
name = ‘nianhua‘ full_name = name*5 print(full_name)
输出结果:nianhuanianhuanianhuanianhuanianhua
二、数字
1. 整数
在python中,整数可执行的运算:
#加法 a1 = 1 a2 = 2 a3 = a1+ a2 #减法 a4 = a2 - a1 #乘法 a5 = a1 * a2 #除法 a6 = 100/10 #幂次方,2的3次方 a7 = 2**3 #取余 a8 = 39%8 #只获得商的整数部分,如39//8=4 a9 = 39//8
2.浮点数
原文:https://www.cnblogs.com/gysym/p/10739459.html