摘要: db ={} def newuser(): prompt = 'login desired:' while True: name = raw_input(prompt) if db.has_key(name): prompt = 'name taken,try another.' continue ... 阅读全文
posted @ 2016-06-22 11:04 你好呀。 阅读(1198) 评论(0) 推荐(0) 编辑
摘要: import keyword import string alp = string.letters +'_' nums = string.digits print "welcome to identifier check v1.0." print "you have to enter two char to identifier." keywords= keyword.kwlist myinp... 阅读全文
posted @ 2016-06-21 10:33 你好呀。 阅读(177) 评论(0) 推荐(0) 编辑
摘要: s = 'abcde' for i in [None] + range(-1,-len(s),-1): print s[:i] #abcde #abcd #abc #ab #a 阅读全文
posted @ 2016-06-21 09:48 你好呀。 阅读(149) 评论(0) 推荐(0) 编辑
摘要: # -*- coding:utf-8 -*- from sys import exit from random import randint wendangzidian = {'1':"""The Gothos of PLANET Percal #25 have invaded your ship and destoryed. Your entire crew. You are the la... 阅读全文
posted @ 2016-06-18 14:50 你好呀。 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 使用 try 和 except ExceptionName 来处理异常 如果没有异常产生,except 段会被跳过 如果某处有异常产生,后面的语句会被跳过,如果产生的异常类型和except后的类型一致,except后的语句会被执行 如果发生异常,但和except后的类型不一致,异常会传递到try语句 阅读全文
posted @ 2016-06-16 22:19 你好呀。 阅读(94) 评论(0) 推荐(0) 编辑
摘要: python 游戏内容:选择正确的道路回到家中。 游戏背景:主人公小米忽然被传到奇怪的地方,需要通过各种挑战回到家中。 游戏程序设计思路: 结局:1.主人公小米到家了,恭喜。 2.主人公小米死掉了,游戏结束。 途中各式各样的选择: 1.被智者抓住,需要回答智者的问题才能通过。 ①智者问,鸡生蛋还是蛋 阅读全文
posted @ 2016-06-16 21:59 你好呀。 阅读(191) 评论(0) 推荐(0) 编辑