摘要: 定义类的时候,若是添加__init__方法,那么在创建类的实例的时候,实例会自动调用这个方法,一般用来对实例的属性进行初使化。比如:class testClass:def __init__(self, name, gender): //定义 __init__方法,这里有三个参数,这个self指的是一 阅读全文
posted @ 2020-04-17 08:06 你走我不走 阅读(631) 评论(0) 推荐(0)
摘要: class Song(object): def __init__(self,lyrics): self.lyrics = lyrics def sing_me_a_song(self): for line in self.lyrics: print(line) happy_bday = Song([ 阅读全文
posted @ 2020-04-16 08:55 你走我不走 阅读(144) 评论(0) 推荐(0)
摘要: states = { "Oregon": 'OR', "Florida": 'FL', "California": 'CA', "New York": "NY", "Michigan": "MI"} cities = { 'CA': 'San Francisco', 'MI': 'Detroit', 阅读全文
posted @ 2020-04-14 11:49 你走我不走 阅读(156) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-04-13 13:00 你走我不走 阅读(107) 评论(0) 推荐(0)
摘要: from sys import exit def gold_room(): print("This room is full of gold . How much do you take.") choice = input(">") if "0" in choice or "1" in choice 阅读全文
posted @ 2020-04-11 10:31 你走我不走 阅读(224) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-04-10 16:01 你走我不走 阅读(128) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-04-04 14:57 你走我不走 阅读(179) 评论(0) 推荐(0)
摘要: print("""You enter a dark room with two doorsself.Do you go through door #1 or door #2?""") door = input(">") if door == "1": #注意这里是等于一个字符串“1”,不是数字1 p 阅读全文
posted @ 2020-04-04 14:22 你走我不走 阅读(153) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-04-04 09:18 你走我不走 阅读(100) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-04-04 08:50 你走我不走 阅读(165) 评论(0) 推荐(0)