- 博客(9)
- 收藏
- 关注
转载 python学习09——字典(3)
今天写了一道python字典题目,用了上次字典(2)中的方法,代码如下: 1 json = {'totalCount':'1', 'ID':'1029', 'IP':'10.0.0.1'} 2 3 def find_value(themap, word): 4 if word in themap: 5 return themap[word...
2016-11-08 17:10:00 82
转载 python学习08——类
笨办法学python第42节,这节讲的是类,程序沿用上一节中一个游戏,不同的是这一节用了类的方法。其中改动的代码主要如下原来的最后几句用了这样的代码:ROOMS = { 'death':death, 'central_corridor':central_corridor, 'laser_weapon_armory':laser_weapon_...
2016-10-11 21:36:00 99
转载 Python学习07——字典(2)
笨办法学Python第40节,上次用的第三版的书,这次是第四版的书。这一节的代码如下: 1 cities = {'CA':'San Francisco', 'MI':'Detroit', 'FL':'Jacksonville'} 2 3 cities['NY'] = 'New York' 4 cities['OR'] = 'Portland' 5 6 ...
2016-09-28 12:46:00 122
转载 Python学习06——列表的操作(2)
笨办法学Python第39节之前用的第三版的书,昨天发现内容不对,八块腹肌又给我下了第四版,这次的内容才对上。本节的代码如下: 1 ten_things = "Apples Oranges Crows Telephone Light Sugar" 2 3 print "Wait there's not 10 things in that list, let's fi...
2016-09-28 11:40:00 113
转载 python学习05——字典
笨办法学python第39节这节主要讲解的是字典,首先字典和列表的两个区别是:1. 列表中可以通过数字找到列表中的元素,是数字作为索引的;字典中可以通过任何东西找到想要的元素,即字典可以将一个物件和另外一个东西关联。2. 列表是有顺序的;字典是无序的。(上一节有提到)本节的代码如下: 1 class Song(object): 2 3 def ...
2016-09-24 21:08:00 91
转载 python学习04——列表的操作
笨办法学python第38节如何创建列表在第32节,形式如下:本节主要是讲对列表的操作,首先讲了mystuff.append('hello') 的工作原理,我的理解是,首先Python找到mystuff这个变量,然后进行append()这个函数操作。其中需要注意的是括号()里面有一个额外参数就是mystuff本身。本文练习: 1 # create a ma...
2016-09-21 20:34:00 92
转载 python学习03——设计,与input有关
笨办法学python第36节,我写的代码如下:from sys import exitdef rule(): print "Congratulations! You made the right choice." print "But is also a terrible choice." print "You have to abide b...
2016-09-13 21:33:00 70
转载 python学习——如何判断输入是数字
笨办法学python第35节该节主要是讲分支与函数,主要遇到的问题是python中如何判断输入是数字。首先原代码如下:from sys import exitdef gold_room(): print "This room is full of gold. How much do you take?" next = raw_input("...
2016-09-12 18:05:00 1735
转载 python学习——将while循环改成函数
笨办法学python第33节这一节主要学习内容是while循环,记录内容为将while改成函数,首先源代码如下: 1 i = 0 2 numbers = [] 3 4 while i < 6: 5 print "At the top i is %d" % i 6 numbers.append(i) 7 8 i = ...
2016-09-11 20:33:00 600
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人