自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 笨办法”学Python3,Zed A. Shaw,习题35

习题34代码问题学到的代码letters = ['k', 'd', 'q', 'a']print (letters[1])问题发现不了问题,我不知道写的这个有啥用?学到的1、函数中global声明的作用;2、将while循环函数化,这样修改的时候方便多了。...

2020-11-26 19:48:24 163

原创 “笨办法”学Python3,Zed A. Shaw,习题33

习题33(1)代码问题学到的代码i = 0numbers = []'''源代码:while i < n: print(f"At the top i is {i}") numbers.append(i)#.append是为了增加i进入到numbers这个列表中 i = i + 1 print("Numbers now: ", numbers) print(f"At the bottom i is {i}")'''#以下15-24行是将源代码改为函

2020-11-23 22:49:07 129

原创 “笨办法”学Python3,Zed A. Shaw,习题32

习题32代码问题学到的代码the_count = [1, 2, 3, 4, 5]fruits = ['apples', 'oranges', 'pears', 'apricots']change = [1, 'pennies', 2, 'dimes', 3, 'quarters']# this first kind of for-loop goes through a listfor number in the_count: print(f"This is count {number}

2020-11-21 11:19:15 118

原创 “笨办法”学Python3,Zed A. Shaw,习题31

习题31代码问题学到的代码print("""You enter a dark room with two doors.Do you go through door #1 or door #2?""")door = input("> ")if door == "1": print("There's a giant bear here eating a cheese cake.") print("What do you do?") print("1. Take the

2020-11-19 21:44:24 100

原创 “笨办法”学Python3,Zed A. Shaw,习题29+30

习题29代码问题学到的代码people = 20cats = 30dogs = 15if people < cats:#同“def”一样,用“:”表示一个程序块。 print ("Too many cats! The world is doomed!")# 同“def”一样,用开头缩进4个来表示这是一个程序块。if people > cats: print ("Not many cats! The world is saved!")if people <

2020-11-17 21:00:01 78

原创 “笨办法”学Python3,Zed A. Shaw,习题25

习题25代码遇到问题学到的代码def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ')#用空格" "拆分stuff。 return wordsdef sort_words(words): """Sorts the words.""" return sorted(words)#将words重新排(默认升)序def print

2020-11-13 21:13:40 77

原创 “笨办法”学Python3,Zed A. Shaw,习题26

习题25代码遇到问题学到的代码def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ')#用空格" "拆分stuff。 return wordsdef sort_words(words): """Sorts the words.""" return sorted(words)#将words重新排(默认升)序def print

2020-11-11 21:40:06 93

原创 “笨办法”学Python3,Zed A. Shaw,习题24

习题21代码遇到问题学到的代码print("Let's practice everything.")print('You\'d need to know \'bout escapes with \\ that do:')print('\n newlines and \t tabs.')poem = """\tThe lovely worldwith logic so firmly plantedcannot discern \n the needs of lovenor comprehe

2020-11-08 20:47:42 85

原创 “笨办法”学Python3,Zed A. Shaw,习题23

习题23代码遇到问题学到的代码"""import sysscript, encoding, error = sys.argv"""from sys import argvscript, encoding, error = argvdef main(language_file, encoding, errors): line = language_file.readline() # https://www.runoob.com/python/file-readline.html

2020-11-08 20:44:29 166

原创 “笨办法”学Python3,Zed A. Shaw,习题21

习题21代码遇到问题学到的代码遇到问题1、学到的1、

2020-08-16 21:03:13 142

原创 “笨办法”学Python3,Zed A. Shaw,习题20

习题20代码遇到问题学到的代码from sys import argvscript, input_file = argvdef print_all(f): print(f.read())#定义一个print_all函数,用来列印f文件的所有内容def rewind(f): print(f.seek(0))#定义一个rewind函数,用来将文件f的搜索位置归至0def...

2020-05-03 21:40:09 116

原创 “笨办法”学Python3,Zed A. Shaw,习题19

习题19代码遇到问题学到的代码def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"You have {cheese_count} cheeses!") print(f"You have {boxes_of_crackers} boxes of crackers!") print("Man t...

2020-05-03 19:55:32 154

原创 习题18-代码修改

习题18-代码修改原代码遇到问题修改后的代码原代码# this one is like your scripts with argvdef print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") #this is an error example, you should put...

2019-08-25 12:22:49 251

原创 “笨办法”学Python3,Zed A. Shaw,习题18

习题17代码遇到问题学到的代码# this one is like your scripts with argvdef print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") #this is an error example, you should put "inpu()" ...

2019-08-23 08:08:56 156

原创 “笨办法”学Python3,Zed A. Shaw,习题17

习题17代码遇到问题学到的代码from sys import argvscript, filename = argvprint(f"We're going to erase {filename}.")print("If you don't want that, hit CTRL-C (^C).")#这句里的“CTRL-C”和下一句的”return“有用吗?print("If you...

2019-08-13 08:14:07 97

原创 Python3自习-日记本

自习代码遇到问题学到的代码import timeDiaryDate = time.strftime("%Y%m%d-%H%M%S", time.localtime())target = open(f"{DiaryDate}.txt", 'w+')txt = input("Your Diary:")while txt != "endendend": target.write(f"...

2019-08-11 12:50:30 329

原创 “笨办法”学Python3,Zed A. Shaw,习题16

习题16代码遇到问题学到的代码from sys import argvscript, filename = argvprint(f"We're going to erase {filename}.")print("If you don't want that, hit CTRL-C (^C).")#这句里的“CTRL-C”和下一句的”return“有用吗?print("If you...

2019-08-11 10:45:43 73

原创 “笨办法”学Python3,Zed A. Shaw,习题15

习题15代码遇到问题学到的代码from sys import argvscript, filename = argvtxt = open(filename)#txt = filename.open()#don't work.print(f"Here's your file {filename}:")print(txt.read())#read是个命令,txt是执行read命令的...

2019-08-11 08:11:15 109

原创 “笨办法”学Python3,Zed A. Shaw,习题14

习题14代码遇到问题学到的代码遇到问题argv并不是很懂学到的1、argv的四个参数在后面并不能改;(so, input是在运行脚本时传递参数,而argv这个脚本就是在运行脚本前传递参数,且在脚本运行时并不能改变参数?不知道是不是这样)2、一个新的解释方法:print(">>>> argv = ", repr(argv))3、argv的参数数量还可以增加或...

2019-08-04 20:08:03 118

原创 “笨办法”学Python3,Zed A. Shaw, 习题13

习题13代码遇到问题学到的代码from sys import argv# read the WYSS aection for how to run thisscript, first, second, third = argvprint(">>>> argv = ", repr(argv))#还是要看视频啊,这一段书上没有print("The script is...

2019-06-13 17:21:54 196

原创 “笨办法”学Python3,Zed A. Shaw, 习题12

习题12代码遇到问题学到的代码age = input("How old are you?")height = input("How tall are you?")weight = input("How much do you weight?")print(f"So, you're {age} old, {height} tall and {weight} heavy.")print...

2019-06-13 16:15:06 151

原创 “笨办法”学Python3,Zed A. Shaw, 习题11

习题11代码遇到问题学到的代码print("How old are you?", end = " ")age = input()print("How tall are you?", end = " ")height = int(input())print("How much do you weight?", end = " ")weight = str(input())#可以输入各...

2019-06-12 15:58:56 140

原创 “笨办法”学Python3,Zed A. Shaw, 习题10

习题10代码遇到问题学到的代码tabby_cat = "\tI'm tabbed in."persian_cat = "I'm split\non a line."backslash_cat1 = "1 - I'm \\ a \\ cat."backslash_cat2 = "2 - I'm \ a \ cat."#这种使用\的情况//和/是一样的效果backslash_cat3 = ...

2019-06-11 21:35:15 307

原创 “笨办法”学Python3,Zed A. Shaw, 习题9

习题9代码遇到问题学到的代码days = "Mon Tue Wed Thu Fri Sat Sun"months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"#\n是文本里另起一行的换行符years = """201920202021"""print("Here are the days: ", days)print("Here ar...

2019-06-10 22:51:45 140

原创 “笨办法”学Python3,Zed A. Shaw, 习题7

习题7代码遇到问题学到的代码print("mary had a little lamb.")#用法1n = "snow"x = f"Its fleece was white as {n}."print("1 - " + x)#用+连接,没用空格直接连上去print("1 - " , x)#用,连接,会空一格,随便,前加不加空格,或者加多少空格,效果一样print("1 - " ...

2019-06-10 17:30:30 118

原创 “笨办法”学Python3,Zed A. Shaw, 习题8

习题8代码遇到问题学到的代码formatter = "{} {} {} {}"print("1 - " + formatter.format(1, 2, 3, 4))print("2 - " + formatter.format("one", "tow", "three", "four"))print("3 - " + formatter.format(True, False, Fals...

2019-06-10 16:57:54 137

原创 “笨办法”学Python3,Zed A. Shaw, 习题6

习题6代码遇到问题学到的代码types_of_people = 10x2 = "There are {} types of people."x1 = f"There are {types_of_people} types of people."binary = "binary"do_not = "don't"y2 = "Those who know {} and those who...

2019-06-09 19:01:47 244

原创 “笨办法”学Python3,Zed A. Shaw, 习题4~5

习题4代码遇到问题学到的代码my_name = "YingXu"my_age = 35my_height = 165my_weight = 63.7my_eyes = 'Black'my_teeth = 'White'my_hair = 'Black'print(f"Let's talk about {my_name}.")print(f"He's {round(my_hei...

2019-06-09 17:07:06 204

原创 “笨办法”学Python3,Zed A. Shaw, 习题3

习题3代码遇到问题学到的代码遇到问题1、赋值运算这段,直接使用了数字进行计算,得不到想要的结果;2、学到的1、运行程序的方式:python ** . ***2、加注释的方式,就是在最前面加个"#"...

2019-06-09 14:53:05 100

原创 “笨办法”学Python3,Zed A. Shaw, 习题1~2

习题1~2遇到问题学到的遇到问题如果要运行一个程序,在powershell中,必须尽到该程序所在的文件夹;学到的1、运行程序的方式:python ** . ***2、加注释的方式,就是在最前面加个"#"...

2019-06-09 13:02:32 103

原创 “笨办法”学Python3,Zed A. Shaw, 习题0

习题0遇到问题学到的遇到问题本以为这一节装个软件的事,缺遇到了一系列的问题:1、一开始,两台电脑其中一台上的win7是自己装的阉割版,没法使用powershell,搞了360的系统安装软件,把系统重装补齐了;2、接着重装过的电脑上,装了python缺无法正常启动,提示“丢失api-ms-win-crt-runtime-l1-1-0.dll”,查了百度,发现是少了C++2015的库没装,装了...

2019-06-06 18:55:48 268

原创 Arduino-003-20181230-触摸键控制LED

代码 #define led 2void setup() { pinMode(led,OUTPUT); Serial.begin(9600);}void loop() { if (analogRead(A5) &gt; 1000)//如果只是“&gt;0”,LED会一直闪 {digitalWrite(led,HIGH); } elsedigitalWrite(led,...

2018-12-30 23:45:40 385

空空如也

空空如也

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

TA关注的人

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