#!/usr/bin/python
#python version 3.0+
i=20 #整形,int()
f=23.45 #浮点型,float()
b=True #逻辑型,bool(),只能选值:True|Flase
bs=b'\x00\x01' #字节,bytes()
ba=bytearray(b'\x00\x01') #字节,bytearray()
str0='123' #字符串 ,不可格式化的字符串,str()
str1="Hello,{0}".format('coco') #字符串,可格式化的字符串
ls=[1,2,3,'4','5'] #列表 ,list()
fls=(1,2,3,'4','5') #元组,既不可变列表 tuple()
set={1,2,3,ls} #集合,set()
map1={1:ls, 2:set} #字典,dict()
#测试
username='Rik'
password='qwer1234'
"{0}'s password is {1}".format(username, password)
"{name} was born in {country}".format_map(Default(name='Guido')) #version 3.2+
Python入门:内置基础类型
最新推荐文章于 2024-09-03 16:02:15 发布