- 博客(13)
- 收藏
- 关注
原创 笨办法学python 习题48---笔记
扫描器: lexicon = { "north":'directions', "south":'directions', "east":'directions', "west":'directions', "go": 'verb', "kill": 'verb', "eat": 'verb', "the": 'stop', &
2018-10-21 19:37:45
828
原创 笨办法学python-- 习题46 47笔记
使用cmd运行power shell nosetests: ---对当前目录及其以下目录内含test的文件进行检测; cd .. 返回上一层文档 mv 重命名 进入虚拟环境 .\.venvs\lpthw\Scripts\activate 设置初始文件 new-item -type file NAME/__init__.py 删除初始的文件rm NAME/__i...
2018-10-20 16:34:33
1806
原创 笨办法学pythonex45--习题笔记
from sys import exit from random import randint from textwrap import dedent class Scene(object): def enter(self): print("此场景尚未配置完成") print("对它进行子类化并实现输入()") exit(1) class Engine(object): d...
2018-10-20 09:43:54
628
原创 笨办法学python3--习题43笔记(借鉴他人)
from sys import exit from random import randint from textwrap import dedent class Scene(object): def enter(self): print("This scene is not yet configured此场景尚未配置.") print("Subclass it and imple...
2018-10-07 10:17:07
2310
3
转载 笨办法学python3日常问题解决
1)类:用来描述具体相同的属性和方法的对象的集合 2)对象:通过类定义的数据结构实例 3)类设计的要点:名称、属性(特征)、方法(行为,也就是函数) #其中的方法__init__(self,name,age) 是固定写法 class Cat(): """模拟小猫的类""" def __init__(self,name,age): """初始化属性name和age...
2018-10-06 19:27:24
309
转载 笨办法学Python3习题42 对象、类及从属关系 --习题
#-*-coding:utf-8-*- ## Animal is-a object (yes, sort of confusing) look at the extra credit class Animal(object): pass ## Dog is-a Animal class Dog(Animal): def __init__(self, name): ...
2018-10-04 17:15:12
1704
原创 笨办法学python3习题41学习面向对象术语--笔记
“%%%”, “***”, “@@@”只是要替换的随机选择的单词 random模块 random模块作用是返回随机数,只要跟随机元素相关的,都可以使用它 random.random()函数是这个模块中最常用的方法了,它会生成一个随机的浮点数,范围是在0.0~1.0之间。 random.uniform()正好弥补了上面函数的不足,它可以设定浮点数的范围,一个是上限,一个是下限。 random.ran...
2018-10-04 13:08:37
3802
原创 笨办法学python习题40——笔记
开头便出现了两处错误 TypeError: Song() takes no arguments def __init__(self,lyrics): 第一处是 init 写成了 int 第二处是双下划线__写成了单下划线_ 1.类(class):类就是一个模板,用于生成实例的内存空间。 2.实例:类的具体存在 类的实例化中,变量保存在栈内存中,存放堆内存地址 实例化的内容保存在堆内...
2018-09-29 19:55:33
802
1
原创 笨办法学python 习题38--笔记
列表: 将值放入方括号中即创建列表。 names = ["Dava","Ann","Mark"] pop() 函数: 用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。 list.pop([index=-1]) obj – 可选参数,要移除列表元素的索引值,不能超过列表总长度,默认为 index=-1,删除最后一个列表值。 join() 方法 用于将序列中的元素以指定的字..
2018-09-28 14:52:38
644
原创 笨办法学python 习题32--笔记
for循环 for 变量 in列表: 过程 例如: for x in cla: 循环语句for 自定义的x拿来循环获得cla里面的值 range()的用法: range(stop) range(start, stop[, step]) start: 计数从 start 开始。默认是从 0 开始。例如range(5)等价于range(0, 5); stop: 计数...
2018-09-25 16:48:15
277
原创 笨办法学python 习题26
原文是: print("How old are you?", end=' ') age = input() print("How tall are you?", end=' ') print("How much do you weigh?", end=' ' weight = input() print(f"So, you're {age} old, {height} tall and {wei...
2018-09-22 10:43:38
672
原创 《笨办法学python》习题25——笔记
原文习题 def break_words(stuff): """This function will break up words for us """ words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" #排序 return sorted(words) de
2018-09-22 10:10:59
329
原创 新手学python学习中
format()用法 print(“Its fleece was white as {}.”format(‘snow’)) snow为字符串不是变量,变量名不带引号 format() f是’格式化‘ my_name = “joke” print(f”Let’s talk about {my_name}”) format()还与%类似 print(format(year,“3d”)...
2018-09-12 15:53:28
365
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅