您的位置:首页 > 编程语言 > Python开发

python——内置类型——整型 浮点型 字符串 布尔型 空型

2017-04-12 16:04 363 查看

整型

十进制:123,456
八进制:0123,0456
十六进制:0x7abc,0X8def

浮点型

十进制(必须包含小数点):123.456,.123,123.
科学计数法(e或E前后必须有值):123e3,4.56E6,.789e9

字符串

用单引号或双引号包括,但不可混搭使用
多个字符串拼接
支持转义
前缀r:字符串内不转义
'''...''':字符串跨行表示
print '1:first,second,third'
print '2:first,'"second,"'third'
print '3:first,\nsecond,\nthird'
print r'4:first,\nsecond,\nthird'
print '''5:first,
second,
third'''
print '''6:first,
second,
third,''''fourth,'"fifth"

output:
1:first,second,third
2:first,second,third
3:first,
second,
third
4:first,\nsecond,\nthird
5:first,
second,
third
6:first,
second,
third,fourth,fifth

布尔型

True
False

空型

None,类似于java的null,oc的nil
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息