python数据类型详解(全面)
1、字符串 1.1、如何在Python中使用字符串 a、使用单引号(') 用单引号括起来表示字符串,例如: str='this is string'; print str; b、使用双引号(") 双引号中的字符串与单引号中的字符串用法完全相同,例如: str="this is string"; print str; c、使用三引号(''') 利用三引号,表示多行的字符串,可以在三引号中自由的使用单引号和双引号,例如: str='''this is string this is pythod string this is string''' print str; 2、布尔类型 bool=False; print bool; bool=True; print bool; 3、整数 int=20; print int; 4、浮点数 float=2.3; print float; 5、数字 包括整数、浮点数。 5.1、删除数字对象引用,例如: a=1; b=2; c=3; del a; del b, c; \#print a; #删除a变量后,再调用a变量会报错 5.2、数字类型转换 int(x [,base]) 将x转换为一个整数 float(x ) 将x转换到一个浮点数 complex(real [,imag]) 创建一个复数 str(x) 将对象x转换为字符串 repr(x)