标签:ict list count() str 容器 The class index named
目录
坑的编码 | 内容 |
---|---|
Py006-1 | len() 的使用场合 |
# 这更像是一种总结吧
str1 = "I am YorkFish."
list1 = [‘I‘, ‘am‘, ‘YorkFish‘]
tuple1 = (‘I‘, ‘am‘, ‘YorkFish‘)
set1 = {‘I‘, ‘am‘, ‘YorkFish‘}
dict1 = {1:‘I‘, 2:‘am‘, 3:‘YorkFish‘}
print("len(str1) =", len(str1))
print("len(list1) =", len(list1))
print("len(tuple1) =", len(tuple1))
print("len(set1) =", len(set1))
print("len(dict1) =", len(dict1))
len(str1) = 14
len(list1) = 3
len(tuple1) = 3
len(set1) = 3
len(dict1) = 3
不止是 len(),如 count()、index() 等都是“多才多艺”的。
我的学识有限,如果有同学、老师或者前辈看到我写的东西,发现错误之处,还请不吝赐教!谢谢!
标签:ict list count() str 容器 The class index named
原文地址:https://www.cnblogs.com/yorkyu/p/10316052.html