list and dict
2011-09-29 14:26
239 查看
''' Created on 2011-9-29 @author: xgzhao ''' list2 = list('foo') print list2 list2.remove('f') print list2 print [i*2 for i in range(8) if i%2 == 0] print [i for i in reversed(range(8))] fdict = dict((['x', 1], ['y', 2])) print fdict tdict = {} print tdict print fdict.keys(), fdict.values(), fdict.items()
''' Created on 2011-9-29 @author: xgzhao ''' db = {} def newUser(): prompt = 'login desired: ' while True: name = raw_input(prompt) if db.has_key(name): prompt = 'name taken, try another' continue else: break pwd = raw_input('password: ') db[name] = pwd def oldUser(): name = raw_input('login: ') pwd = raw_input('password: ') passwd = db.get(name) if passwd == pwd: print 'Welcome back ', name else: print 'login incorrect' def showmenu(): prompt = """ (N)ew User Login (E)xisting User Login (Q)uit Enter choice = """
相关文章推荐
- python笔记-list and dict
- how to merge dict and list
- sort list and dict
- The Definitive C++ Book Guide and List--reference
- Python基础知识- list ,tuple ,dict 和 set
- 使用python-google-places 一个严重的bug 错误提示:lat_lng must be a dict with the keys, 'lat' and 'lng'
- Add to List 121. Best Time to Buy and Sell Stock,我的解题思路
- Python 中的None以及 == 与 is 的区别,以及判断某个list或者dict元素是否为None
- STL的Vector, List and Deque
- python中的list、dict、string基本操作
- python 之 list,tuple,dict,set
- 【python笔记】python中的list、tuple、set、dict用法简析
- python的dict,set,list,tuple简单分析
- Python:list、dict、string
- python list元素为dict时的排序
- recursive and iterative ways to reverse a LinkedList
- SortedDictionaryGeneric and SortedListGeneric
- Python中内置数据类型list,tuple,dict,set的区别和用法
- python 基础2 编码转换 pycharm 配置 运算符 基本数据类型int str list tupple dict for循环 enumerate序列方法 range和xrange
- decorator pattern and linked list