码迷,mamicode.com
首页 > 编程语言 > 详细

python 常用数据类型

时间:2017-01-11 14:33:02      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:多行   字符串   相同   span   利用   表示   print   数字   布尔类型   

目录
1、字符串
2、布尔类型
3、整数
4、浮点数
5、数字
6、列表


1.字符串

a、使用单引号(‘)或者双引号(")

引号中的字符串与双引号中的字符串用法完全相同,例如:
str1=‘this is string1‘;

str2= "this is string2"

print str1,str2;

b、使用三引号(‘‘‘)
利用三引号,表示多行的字符串,可以在三引号中自由的使用单引号和双引号,例如:
str=‘‘‘this is string
this is  string
this is string‘‘‘
print str;

2.布尔类型

True or False

>>> type(True)
<class ‘bool‘>
>>> type(False)
<class ‘bool‘>
利用布尔类型进行判断:
>>> 1 + 1 == 2
True
>>> 1 + 1 == 3
False

3.整数

 

python 常用数据类型

标签:多行   字符串   相同   span   利用   表示   print   数字   布尔类型   

原文地址:http://www.cnblogs.com/python007/p/6273301.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!