自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 儿歌

拍拍,拍拍手,我们一起拍,拍拍拍拍拍拍拍,Shmily拍拍手。拍拍,拍拍手,Jayden拍拍手,拍拍拍拍拍拍拍,Alba拍拍手。调子(row your board)

2017-03-17 19:07:06 734

原创 class,类的详解, python, 笨方法学python

#coding=utf-8class Song(object): def __init__(self, geci): #__init__(每条横线都是两个字符) self.geci = geci #将geci这个变量值(是来自实例化的object?),赋予给self.geci def sing_me_a_song(self): for line in

2017-03-16 21:03:42 2590

原创 字典实战应用,笨方法学python

#coding=utf-8#creat a mapping from child to account_namechildren = { 'Hannibal': 'Des001', 'Shmily': 'Angel136', 'James': 'Feng128', 'Jayden': 'Luo125',}#Creat a basic set of account a

2017-03-15 22:28:37 390

原创 详细解析字典,learn python the hard way, 笨方法学python

#coding=utf-8#create a mapping of provinces to suoxieprovinces = { 'Guangdong': 'Yue', 'Sichuan': 'Chuan', 'Hainan': 'Qiong', 'Fujian': 'Min', 'Daiwan': 'Dai',}#create a basic set

2017-03-15 22:02:27 495

转载 列表的操作,习题38,learn python the hard way.

#coding=utf-8ten_things = "Apples oranges Crows Telephone Light Sugar"print "Wait there's not 10 things in that list, let's fix that."stuff = ten_things.split(' ') #str.split(' ', num) num为分割次数。split

2017-03-13 22:32:21 333

转载 try, excep, else, python关键词

python标准异常 异常名称 描述BaseException 所有异常的基类 SystemExit 解释器请求退出 KeyboardInterrupt 用户中断执行(通常是输入^C) Exception 常规错误的基类 StopIteration 迭代器没有更多的值 GeneratorExit 生成器(generator)发生异常来通知退出 StandardErro

2017-03-12 14:28:39 481

转载 关键词break, python

x = 4while True: x += 1 print x if x > 50: break用在满足某个条件,需要立刻退出当前循环时(跳出循环),break语句可以用在for循环和while循环语句中。简单的说,break语句是会立即退出循环,在其后边的循环代码不会被执行。

2017-03-12 14:10:50 713

转载 python,关键词pass

for letter in 'python': if letter == 'h': pass print " This is pass block" print "Current letter:", letterprint " Goodbye"for letter in 'Patrick': if letter == 'r':

2017-03-12 13:39:27 860

转载 .realines()应用,将中文文章和对应英文文章,按顺序的合并在一起

chinese = open('new2.txt', 'r')english = open('new.txt', 'r')translate = open('translate.txt', 'w')f_chinese = chinese.readlines() #f_chinese是个list,因为.readlines可以把文件处理成list,每行就是相当一个元素。f_english = e

2017-03-12 10:15:56 644

原创 readlines and readline的区别

#coding=utf-8#open a filenew = open('new.txt', 'r')print "The name of the file:%s" % newline = new.readlines()print "Read line1:%s" % (line)line = new.readlines()print "this is 2:", line #前面已经读取

2017-03-12 09:40:48 723

原创 Python, file readline() method

#coding=utf-8#open a filenew = open('new.txt', 'r')print "The name of the file:%s" % newline = new.readline(1)print "Read line1:%s" % (line)line = new.readline()line = new.readline()print "Read

2017-03-12 09:23:30 321

原创 读写文件,python. learn python the hard way

#coding=utf-8poem = "\t I'm trying to writ this into my file,,ooo"def method_one(): f = open('new.txt', 'w') #open new.txt as file 确认在终端,你已经cd进入了文件所在文件夹。否则Open不出来 f.write(poem) #write poem in

2017-03-12 08:54:04 445

原创 list.pop()函数的用法,python

#coding=utf-8my_list = ['jj', 'ee', 'c']print "A List:", my_list.pop() #pop()函数用于移除列表中一个元素,默认最后一个元素,并返回该元素的值,所以这里打印出来的是CC,即是被删除了的那个元素的值print my_list #'c'被删除后的my_listprint "B list:", my_list.pop(1) #所

2017-03-10 00:14:30 6356

转载 assert语句,python, 笨办法学python

my_list = ['Items']assert len(my_list) >= 1my_list.pop()assert len(my_list) >= 1#list.pop()函数用来移除列表的某个元素#assert,用来声明某个条件是真的,当assert语句失败时,会引发AssertError

2017-03-10 00:03:58 464

原创 python全局变量和局部变量, global

#coding=utf-8def test(): x = 2 print "x is:", x print "So, we defien local x 2."x = 50 #主块Xtest() #运行函数print "X outside function is still the same", x #证明运行函数没有影响主块X的值。def test_2(): g

2017-03-07 23:28:23 578

原创 python, del[] 用法, 笨方法学python

city = ['GZ', 'SZ', 'HY']def del_function(): print "This is a function to remove an element from list\n." print "Before" for x in city: print "This is before list: %s\n" % x del

2017-03-07 22:57:18 586

原创 习题35,36分支与函数,设计和调试,笨方法学python,中文版游戏

#coding=utf-8from sys import exitname = raw_input("请为自己取名>>>>>")def start(): city_list = ['广州','深圳', '河源'] for city in city_list: print "这是你的选择之一:%s." %city #如果这里接下来还有其他的print

2017-03-07 21:12:56 1003

转载 习题35,分支和函数,笨方法学python

#coding=utf-8from sys import exitdef gold_room(): print "This room is full of gold. How much do you take?" next = raw_input(">") if "0" in next or "1" in next: how_much = int(next)

2017-03-05 16:19:35 1374

原创 while循环和for循环的比较,习题33,笨方法学python

1)for 循环 和range()函数:def worker_salary(target_salary, increase_per_month): money_all_he_got = [] for each_month_salary in range(0, target_salary, increase_per_month): print " at the momen

2017-03-05 11:50:08 1996

原创 while循环,习题33,笨办法学python

def worker_salary(target_salary, increase_per_month): initial_salary = 0 money_all_he_got = []  while initial_salary   print "At the moment, his salary is %d" % initial_salary  money_all_h

2017-03-05 10:47:25 491

转载 Learn python the hard way_习题32_循环和列表

the_count = [1, 3, 5, 6]fruits = ['apple', 'oranges', 'pears', 'apricots']change = [1, 'pennies', 2, 'dimes', 3, 'quarters']# this first kind of for-loop goes through a list.for people in the_

2017-03-04 21:27:04 297

转载 range()函数。 笨方法学python. 循环和列表。

函数原型:range(start, end, scan):参数含义:start:计数从start开始。默认是从0开始。例如range(5)等价于range(0, 5);              end:技术到end结束,但不包括end.例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5              scan:每次跳跃的间距,默认为1。例如:range(

2017-03-04 16:13:34 612

原创 笨方法学python--习题31---做出决定。

#coding=uft-8print "You are goonna enroll to our school, what's your age (month)"age = raw_input(">")if age >= "18": print " You are a big boy now, welcome to IC." elif age  print "You a

2017-03-04 15:01:48 318

原创 习题30 else 和 if. 附加练习3

#coding=utf-8#赋值people = 20cars = 19buses =15if cars > people and buses  print "Take cars!!!!" elif cars > people or buses > cars: print "TAKE WHATEVER YOU WANT." elif cars

2017-03-04 13:45:42 448

原创 Learn Python the hard way. 习题30. If和else/elif

#coding=utf-8age = int(raw_input("Your age?"))if age > 18: print "your age is", age print "You are an adult." elif age > 12: print "your age is", age print "You are a teenager." el

2017-03-04 13:04:57 302

原创 if 语句----习题29扩展练习。learn python the hard way.

#coding=utf-8#raw_input()函数输出的数据是"str",需要将其处理成数据,使用int()函数,将“str"转换成数据来处理students = int(raw_input("students number"))   fees_per_person = 80cost = students * 3total_income =  students * fees

2017-03-04 09:44:56 310

原创 函数可以返回某些东西。习题21---learn python the hard way.

#coding=utf-8def plus(a, b):    return a + b def jian(a, b):    return a - b def cheng(a, b):    return a * b def chu(a, b):    return a / b x = plus(50, 10)y = jian(50, 10

2017-02-22 19:58:25 342

原创 函数与文件-习题20--learn python the hard way

#coding=utf-8from sys import argvscript, file_name = argvdef print_all(f):   #函数名    print f.read() #函数代码,函数的具体操作 #函数,寻找开头def seek(f):    f.seek(0) #函数,打印一行def print_one_line(w

2017-02-21 22:50:24 263

原创 Python 函数与变量--习题19,learn python the hard way

#coding=utf-8def Total_number_of_students(boys, girls):    print "There are %d boys within the environment." % boys    print "There are %d girls within the environment.\n" % girls#运行方式一:数字pr

2017-02-20 23:31:18 486

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除