自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 twelveth-alien_invasion-alien_settings_blue.py

# -*- coding:utf-8 -*-#li hongliang 2021年03月26日class Settings(): """存储《外星人入侵》的所有设置的类""" def __init__(self): """初始化游戏的设置""" # 屏幕设置 self.screen_width = 1200 self.screen_height = 800 self.bg_color = (0, 0, 255)

2021-04-02 16:47:36 128

原创 twelveth-alien_invasion-alien_invasion_gf_up.py

# -*- coding:utf-8 -*-#li hongliang 2021年03月26日import sysimport pygamefrom settings import Settingsfrom ship import Shipimport game_functions as gfdef run_game(): # 初始化游戏并创建一个屏幕对象 # 初始化pygame、设置和屏幕对象 pygame.init() ai_settings = Set

2021-04-01 18:37:05 127

原创 twelveth-alien_invasion-alien_invasion_gf.py

# -*- coding:utf-8 -*-#li hongliang 2021年03月26日import sysimport pygamefrom settings import Settingsfrom ship import Shipimport game_functions as gfdef run_game(): # 初始化游戏并创建一个屏幕对象 # 初始化pygame、设置和屏幕对象 pygame.init() ai_settings = Set

2021-04-01 18:36:03 149

原创 twelveth-alien_invasion-game_functions.py

# -*- coding:utf-8 -*-#li hongliang 2021年03月26日import sysimport pygamedef check_events(): """响应按键和鼠标事件""" for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit()def update_screen(ai_settings, screen, ship)

2021-04-01 18:35:00 91

原创 twelveth-alien_invasion-alien_invasion_new.py

# -*- coding:utf-8 -*-#li hongliang 2021年03月26日import sysimport pygamefrom settings import Settingsdef run_game(): # 初始化游戏并创建一个屏幕对象 # 初始化pygame、设置和屏幕对象 pygame.init() ai_settings = Settings() screen = pygame.display.set_mode(

2021-03-26 19:00:12 73

原创 twelveth-alien_invasion-alien-settings.py

-- coding:utf-8 --#li hongliang 2021年03月26日class Settings():“”“存储《外星人入侵》的所有设置的类”""def init(self):“”“初始化游戏的设置”""# 屏幕设置self.screen_width = 1200self.screen_height = 800self.bg_color = (230, 230, 230)...

2021-03-26 18:58:04 82

原创 twelveth-alien_invasion-alien_invasion.py

-- coding:utf-8 --#li hongliang 2021年03月26日import sysimport pygamefrom settings import Settingsdef run_game():# 初始化游戏并创建一个屏幕对象pygame.init()screen = pygame.display.set_mode((1200, 800))pygame.display.set_caption(“Alien Invasion”)# 设置背景色bg_color =

2021-03-26 18:57:26 164

原创 twelveth-alien_invasion-12-1.py

-- coding:utf-8 --#li hongliang 2021年03月23日#第11章 武装飞船#12.1 规划项目#在游戏《外星人入侵》中,玩家控制着一艘最初出现在屏幕底部中央的飞船。玩家#可以使用箭头键左右移动飞船,还可使用空格键进行射击。游戏开始时,一群外星人出#现在天空中,他们在屏幕中向下移动。玩家的任务是射杀这些外星人。玩家将所有外星#人都消灭干净后,将出现一群新的外星人,他们移动的速度更快。只要有外星人撞到了#玩家的飞船或到达了屏幕底部,玩家就损失一艘飞船。玩家损失三艘

2021-03-26 18:56:02 102

原创 11-3 test_employee.py

# -*- coding:utf-8 -*-#li hongliang 2020年10月23日# 动手试一试#11-3 雇员:编写一个名为Employee 的类,其方法__init__()接受名、姓和年薪,并#将它们都存储在属性中。编写一个名为give_raise()的方法,它默认将年薪增加5000#美元,但也能够接受其他的年薪增加量。#为Employee 编写一个测试用例,其中包含两个测试方法:test_give_default_#raise()和

2020-10-23 18:23:19 138

原创 11-3 employee.py

# -*- coding:utf-8 -*-#li hongliang 2020年10月23日# 动手试一试#11-3 雇员:编写一个名为Employee 的类,其方法__init__()接受名、姓和年薪,并#将它们都存储在属性中。编写一个名为give_raise()的方法,它默认将年薪增加5000#美元,但也能够接受其他的年薪增加量。#为Employee 编写一个测试用例,其中包含两个测试方法:test_give_default_#raise()和

2020-10-23 18:22:10 109

原创 11.2 测试类

# -*- coding:utf-8 -*-#li hongliang 2020年10月23日#第11章 测试代码#11.2 测试类#在本章前半部分,你编写了针对单个函数的测试,下面来编写针对类的测试。很多程序中都会用到类,因此能够证明你的类能够正确地工作会大有裨益。如果针对类的测试通过了,你就能确信对类所做的改进没有意外地破坏其原有的行为。#11.2.1 各种断言方法#Python在unittest.TestCase类中提供了很多断言方法。前面说过,断言方法检查你认为应该满足的条件是否确实满足

2020-10-23 18:20:16 134

原创 11-2-test_cities1.py

# -*- coding:utf-8 -*-#li hongliang 2020年10月14日#11-2 人口数量:修改前面的函数,使其包含第三个必不可少的形参population,并#返回一个格式为City, Country – population xxx 的字符串,如Santiago, Chile –#population 5000000。运行test_cities.py,确认测试test_city_country()未通过。#修改上述函数,将形参population 设置为可选的。再次运行

2020-10-14 23:39:49 103

原创 11-2-city_functions1.py

# -*- coding:utf-8 -*-#li hongliang 2020年10月14日#11-2 人口数量:修改前面的函数,使其包含第三个必不可少的形参population,并#返回一个格式为City, Country – population xxx 的字符串,如Santiago, Chile –#population 5000000。运行test_cities.py,确认测试test_city_country()未通过。#修改上述函数,将形参population 设置为可选的。再次运行

2020-10-14 23:39:06 109

原创 11-1-test_cities.py

# -*- coding:utf-8 -*-#li hongliang 2020年09月30日#创建一个名为test_cities.py 的程序,对刚编写的函数进行测试(别忘了,你需要导#入模块unittest 以及要测试的函数)。编写一个名为test_city_country()的方法,核实#使用类似于'santiago'和'chile'这样的值来调用前述函数时,得到的字符串是正确的。#运行test_cities.py,确认测试test_city_country()通过了。import un

2020-10-14 19:27:32 188 1

原创 11-1-city_functions.py

# -*- coding:utf-8 -*-#li hongliang 2020年09月30日#11-1 城市和国家:编写一个函数,它接受两个形参:一个城市名和一个国家名。这#个函数返回一个格式为City, Country 的字符串,如Santiago, Chile。将这个函数存储#在一个名为city _functions.py 的模块中。def city_country(city,country): city= city.title() country = country.ti

2020-10-14 19:26:34 145

原创 第11章 测试代码 ——11.1 测试函数

# -*- coding:utf-8 -*-#li hongliang 2020年09月30日#第11章 测试代码#11.1 测试函数#11.1.1 单元测试和测试用例#Python标准库中的模块unittest提供了代码测试工具。单元测试用于核实函数的某个方面没#有问题;测试用例是一组单元测试,这些单元测试一起核实函数在各种情形下的行为都符合要求。#良好的测试用例考虑到了函数可能收到的各种输入,包含针对所有这些情形的测试。全覆盖式测#试用例包含一整套单元测试,涵盖了各种可能的函数使用方式。

2020-10-12 10:04:51 273

原创 Little_Women8.txt

The moment Mrs. Carrol saw the girl’s altered face, she was illuminatedwith a new idea, and exclaimed to herself, “Now I understand itall–the child has been pining for young Laurence. Bless my heart, Inever thought of such a thing!”With praiseworthy d

2020-08-24 09:39:39 2924

原创 10-4 存储数据

-- coding:utf-8 --#li hongliang 2020年08月21日#10.4 存储数据#很多程序都要求用户输入某种信息,如让用户存储游戏首选项或提供要可视化的数据。不管专注的是什么,程序都把用户提供的信息存储在列表和字典等数据结构中。用户关闭程序时,你几乎总是要保存他们提供的信息;一种简单的方式是使用模块json来存储数据。模块json让你能够将简单的Python数据结构转储到文件中,并在程序再次运行时加载该文件中的数据。你还可以使用json在Python程序之间分享数据。更重要的

2020-08-24 09:39:26 98

原创 Little_Women7.txt

CHAPTER THIRTY-FIVEHEARTACHEWhatever his motive might have been, Laurie studied to some purposethat year, for he graduated with honor, and gave the Latin oration withthe grace of a Phillips and the eloquence of a Demosthenes, so hisfriends said. They

2020-08-21 18:11:28 2116

原创 Little_Women6.txt

CHAPTER THIRTY-ONEOUR FOREIGN CORRESPONDENTLondonDearest People, Here I really sit at a front window of the Bath Hotel,Piccadilly. It’s not a fashionable place, but Uncle stopped here yearsago, and won’t go anywhere else. However, we don’t mean to s

2020-08-21 18:10:07 1681

原创 Little_Women5.txt

Little notice was taken of her stories, but they found a market, andencouraged by this fact, she resolved to make a bold stroke for fameand fortune. Having copied her novel for the fourth time, read it toall her confidential friends, and submitted it w

2020-08-21 18:08:40 1550

原创 Little_Women4.txt

MEGThis note, prettily written on scented paper, was a great contrast tothe next, which was scribbled on a big sheet of thin foreign paper,ornamented with blots and all manner of flourishes and curly-tailedletters.My precious Marmee:Three cheers for

2020-08-21 17:39:47 1757

原创 Little_Women3.txt

Mr. Pickwick, Sir:--I address you upon the subject of sin the sinnerI mean is a man named Winkle who makes trouble in hisclub by laughing and sometimes won't write his piece inthis fine paper I hope you will pardon his badness andlet him send a Frenc.

2020-08-21 17:38:38 1977

原创 Little_Women2.txt

“Laurie did it all. I only let her go. Mother, if she should die, itwould be my fault.” And Jo dropped down beside the bed in a passion ofpenitent tears, telling all that had happened, bitterly condemning herhardness of heart, and sobbing out her gra

2020-08-21 17:37:15 1181

原创 dogs.txt

xiaoheihuzicaomeigoueryaya

2020-08-21 17:08:33 91

原创 cats.txt

lucylilyxiximarymiaoxiaojie

2020-08-21 17:07:50 96

原创 Little_Women1.txt

下载地址:http://www.gutenberg.org/ebooks/514

2020-08-21 09:55:59 4387

原创 Moby_Dick.txt

下载地址http://www.gutenberg.org/files/2489/old/

2020-08-21 09:46:19 368

原创 alice.txt

The Project Gutenberg EBook of Alice in Wonderland, by Alice GerstenbergThis eBook is for the use of anyone anywhere at no cost and withalmost no restrictions whatsoever. You may copy it, give it away orre-use it under the terms of the Project Gutenbe

2020-08-20 19:13:48 2059

原创 第10章 文件和异常——10.3 异常

-- coding:utf-8 --#li hongliang 2020年08月13日#10.3 异常#Python使用被称为异常的特殊对象来管理程序执行期间发生的错误。每当发生让Python不知所措的错误时,它都会创建一个异常对象。如果你编写了处理该异常的代码,程序将继续运行;如果你未对异常进行处理,程序将停止,并显示一个traceback,其中包含有关异常的报告。异常是使用try-except代码块处理的。try-except代码块让Python执行指定的操作,同时告诉Python发生异常时怎么办

2020-08-13 19:08:43 188

原创 Programming_survey.txt

I like write code,Thank you for your reply

2020-08-13 16:08:45 58

原创 programming.txt

I love programming.80000000000I also love finding meaning in large datasets.I love creating apps that can run in a browser.I also love finding meaning in large datasets.I love creating apps that can run in a browser.

2020-08-13 16:07:24 51

原创 第10章 文件和异常——10.2 写入文件

-- coding:utf-8 --#li hongliang 2020年08月12日#10.2 写入文件#保存数据的最简单的方式之一是将其写入到文件中。通过将输出写入文件,即便关闭包含程序输出的终端窗口,这些输出也依然存在:你可以在程序结束运行后查看这些输出,可与别人分享输出文件,还可编写程序来将这些输出读取到内存中并进行处理。#10.2.1 写入空文件...

2020-08-12 23:01:37 105

原创 pi_digits.txt

3.1415926535897932384626433832794123071812

2020-08-12 19:00:03 447

原创 learning_python.txt

In Python I can create listIn Python I can understanding variables and simple data typesIn Python I can write if statementIn Python I can use functionIn Python I can create classIn Python I can create dictionaries

2020-08-12 18:59:15 114

原创 第10章 文件与异常:10-1 从文件中读取数据

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar

2020-08-04 16:28:49 145

原创 9.6 类编码风格 +9.7 小结

# -*- coding:utf-8 -*-#li hongliang 2020年06月29日#9.6 类编码风格#类名应采用驼峰命名法,即将类名中的每个单词的首字母都大写,而不使用下划线。实例名和模块名都采用小写格式,并在单词之间加上下划线。"""对于每个类,都应紧跟在类定义后面包含一个文档字符串。这种文档字符串简要地描述类的功能,并遵循编写函数的文档字符串时采用的格式约定。每个模块也都应包含一个文档字符串,对其中的类可用于做什么进行描述。可使用空行来组织代码,但不要滥用。在类中,可使用一个

2020-06-29 18:17:56 106

原创 9.5 Python 标准库——9-13,9-14,9-15

# -*- coding:utf-8 -*-#li hongliang 2020年06月29日#9.5 Python 标准库#字典让你能够将信息关联起来,但它们不记录你添加键—值对的顺序#9-13 使用OrderedDict:在练习6-4 中,你使用了一个标准字典来表示词汇表。请#使用OrderedDict 类来重写这个程序,并确认输出的顺序与你在字典中添加键—值对的顺序一致。#6-4 词汇表2:既然你知道了如何遍历字典,现在请整理你为完成练习6-3 而编写#的代码,将其中的一系列prin

2020-06-29 17:33:20 243

原创 9.5 Python 标准库——9-13

# -*- coding:utf-8 -*-#li hongliang 2020年06月29日#9.5 Python 标准库#字典让你能够将信息关联起来,但它们不记录你添加键—值对的顺序#9-13 使用OrderedDict:在练习6-4 中,你使用了一个标准字典来表示词汇表。请#使用OrderedDict 类来重写这个程序,并确认输出的顺序与你在字典中添加键—值对的顺序一致。#6-4 词汇表2:既然你知道了如何遍历字典,现在请整理你为完成练习6-3 而编写#的代码,将其中的一系列prin

2020-06-29 15:28:08 147

原创 9.4.6 在一个模块中导入另一个模块——导入多个模块的应用文件

# -*- coding:utf-8 -*-#li hongliang 2020年06月27日#9-12 多个模块:将User 类存储在一个模块中,并将Privileges 和Admin 类存储在#另一个模块中。再创建一个文件,在其中创建一个Admin 实例,并对其调用方法#show_privileges(),以确认一切都依然能够正确地运行。from all_user import User #导入模块:all_user中的类:Userfrom user_privileges impor

2020-06-28 00:05:36 510

空空如也

空空如也

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

TA关注的人

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