摘要:
定义类的时候,若是添加__init__方法,那么在创建类的实例的时候,实例会自动调用这个方法,一般用来对实例的属性进行初使化。比如:class testClass:def __init__(self, name, gender): //定义 __init__方法,这里有三个参数,这个self指的是一 阅读全文
摘要:
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([ 阅读全文
摘要:
states = { "Oregon": 'OR', "Florida": 'FL', "California": 'CA', "New York": "NY", "Michigan": "MI"} cities = { 'CA': 'San Francisco', 'MI': 'Detroit', 阅读全文
摘要:
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 阅读全文