Python学习之路--数据类型汇总

s = 'alex'

b = s.encode('u-f-8')

print(b)   # b'alex'

基础数据类型汇总

str 

int

list

bool

dict

循环中不能删除键

tuple 如果元组里面只有一个元素,且不加‘,’ ,那此元素是什么类型,就是什么类型

tu1 =([1])
tu2 =([1],)
print(tu1,type(tu1))
print(tu2,type(tu2))
# [1] <class 'list'>
# ([1],) <class 'tuple'>

set

深浅copy

猜你喜欢

转载自www.cnblogs.com/rssblogs/p/10916510.html