补充
作者:互联网
补充
.join用"" 连接列表返回字符串
s = "".join([‘ab’, ‘bb’, ‘cc’]) 迭代便利
print(s)
‘aa_bb_cc’
s = “_”.join(“abc”) 迭代便利
print(s)
‘a_b_c’
.split("") 用""分割
dic = dict.fromkeys(‘abc’, ‘aaa’)和原来的字典没有关系 生成新字典 直接用类名访问
print(dic)
{‘a’: ‘aaa’,‘b’: ‘aaa’,‘c’: ‘aaa’}
for循环中不可以删除被循环的列表和字典
列表删不全
字典不可以在循环中改变长度会报错
lst = [1,2,3,4,5]
lst1 = []
for i in lst:
lst1.append(i)
for i in lst1:
lst.remove(i)
标签:aaa,lst1,补充,lst,print,join,字典 来源: https://blog.csdn.net/Since_I_was_32/article/details/113837277