1.1Python数据类型:数字
1.2整型和浮点型:
int 整数型
long 长数型
float 浮点型
complex 复数
1.3运算符
*乘方运算符
乘法运算符
/除法运算符
//整除运算符
%除余运算符
1.4Python的字符串
1.5转义字符
\n 换行符
\t 制表符
\r 回车
\\ 表示\
\' 表示一个单引号,而不是字符串的结果
1.6操作字符串
网络查询此处不做解释
1.7格式化字符串
%c 单个字符
%d 十进制整数
%o 八进制整数
%s 字符串
%x十六进制整数 字母小写
%X十六进制整数 字母大写
1.8Python数据类型:列表和元组
1):创建和操作列表[]
list.append()追加成员
list.count()计算出现的次数
示例:
list = [] #定义一个空列表
list.append(1) #添加成员
2):创建和操作元组
元组的特性与列表基本相同,元组是以()包围的数据集合,与列表不同的是元组数据一旦确立就不会被改变
1.9Python数据类型:字典
{}表示方法
字典可以改变
dic.clear()
dic.copy()
dic.get(k)
2.0python数据类型:文件
file = open(‘c:/python.txt’,'w')
file.write('python\n')
#分清什么是写入,什么是读,什么是覆盖
代码演示
a = []
for i in range (10):
s = str(i) + '\n'
a.append(s)
file.writelines(a)
file.close()
file = open('c:/python.txt','r')
s = file.read()
print(s)