zhu327

字典的key可是是 strings,numbers,tuples
in可以判断Dicts中是否有该key
dict.get(\'a\')返回键\'a\'对于的值,如键\'a\'不存在,返回None
dict.keys()与dict.values()返回由所有key或values生成的list
dict.items()返回以(key, value)为元的list

 

for k, v in dict.items(): 实现字典的迭代

 

字典的格式输出

1 hash ={\'word\':\'garfield\', \'count\':42}  
2 s =\'I want %(count)d copies of %(word)s\'% hash
3 # %d for int, %s for string
4 # \'I want 42 copies of garfield\'

Del
删除变量,列表中的元,字典中的元

 

文件 f = open(\'name\', \'a\') a表示append,\'rU\'

 
1 File Unicode
2 import codecs
3 f = codecs.open(\'foo.txt\', \'rU\', \'utf-8\')

分类:

技术点:

相关文章:

  • 2021-08-01
  • 2022-01-08
  • 2021-06-03
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
猜你喜欢
  • 2021-12-26
  • 2021-11-03
  • 2021-10-06
  • 2021-12-22
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
相关资源
相似解决方案