自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 《笨方法学习python3》练习18: Names,Variables,Code,Functions: def

EX18: Names,Variables,Code,Functions例子:def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2

2021-03-26 18:36:36 141

原创 《笨方法学习python3》练习17: More Files: len, exists

EX17: More Files例子:# 将一个文档的内容复制到另一个文档from sys import argvfrom os.path import exists# 在运行程序之前需要具体填入文件名,如果文件名不存在,则会新建一个文件script, from_file, to_file = argvprint(f"Copying from {from_file} to {to_file}")# indata = open(from_file).read()in_file = o

2021-03-26 18:34:17 225 3

原创 《笨方法学习python3》练习16: Reading and Writing Files: write, seek, readline, truncate, open

EX16: Reading and Writing Files例子:from sys import argvscript, filename = argvprint(f"We're going to erase {filename}.")print("If you don't want that, hit CTRL-C (^C).")print("If you do want that, hit RETURN.") input("?")print("Opening the fil

2021-03-26 18:28:35 229

原创 《笨方法学习python3》练习15: Reading Files:open, close, read, repr

EX15: Reading Files例子:from sys import argv# 命令行输入script, filename = argv# 打开文件,并且返回文件操作对象txt = open(filename) # 有的时候open需要添加参数:encoding = "utf-8"# 使用 f-string 调用 filenameprint(f"Here's your file {filename}:")# 读取整个文件,将文件内容放到一个字符串变量中。print(tx

2021-03-26 18:24:40 229

原创 《笨方法学习python3》练习14: Prompting and Passing

EX14: Prompting and Passing例子:from sys import argvscript, user_name = argvprompt = '>'print(f"Hi {user_name}, I'm the {script} script.")print("I'd like to ask you a few questions.")print(f"Do you like me {user_name}?")likes = input(prompt)

2021-03-26 18:21:19 137

原创 《笨方法学习python3》练习13: Parameters, Unpacking, Variables

EX13: Parameters, Unpacking, Variables例子:from sys import argvscript, first, second, third = argvprint("The script is called:", script)print("Your first variable is:", first)print("Your second variable is:", second)print("Your third variable is:",

2021-03-26 18:18:01 178 2

原创 《笨方法学习python3》练习12: Prompting People

EX12: Prompting People例子: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.")学习内容:pydoc;pydoc查看、生成帮助文档,所生成的文档是HTML格

2021-03-26 18:16:26 97 1

原创 《笨方法学习python3》练习11: Asking Question

EX11: Asking Question例子:print("How old are you?", end=' ')age = input()print("How tall are you?", end=' ')height = input()print("How much do you weight?", end=' ')weight = input()print(f"So...

2019-10-10 15:24:28 338

原创 《笨方法学习python3》练习10: What Was That?

EX10: What Was That?例子:tabby_cat = "\tI'm tabbed in."persian_cat = "I'm split\non a line."backslash_cat = "I'm \\ a \\ cat."fat_cat = """I'll do a list:\t* Catfood\t* Fishies\t* Catnip\n\t...

2019-10-10 14:58:18 198

原创 《笨方法学习python3》练习9: Printing,Printing,Printing

EX9: Printing,Printing,Printing例子:days = "Mon Tue Wed Thu Fri Sat Sun"months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"print("Here are the days: ", days)print("Here are the months: ", months...

2019-10-09 23:31:13 152

原创 《笨方法学习python3》练习8: Printing,Printing

EX8: Printing,Printing例子:formatter = "{} {} {} {}"print(formatter.format(1, 2, 3, 4))print(formatter.format("one", "two", "three", "four"))print(formatter.format(formatter, formatter, formatte...

2019-10-09 23:27:44 606

原创 《笨方法学习python3》练习7: More Printing

EX7: More Printing例子:print("Mary had a little lamb.")# 使用format将snow 加入句子中print("Its fleece was white as {}.".format('snow'))# 转化为f-string:print (f"Its fleece was white as {'snow'}.")print("An...

2019-10-09 23:19:26 212

原创 《笨方法学习python3》练习6: Strings and Text

EX6: Strings and Text例子:# 给 types_of_people 赋值:10types_of_people = 10# 将字符串赋值给 x ,使用 f-string 将 type_of_people 嵌入 x 中x = f"There are {types_of_people} types of people."# 赋值binary = "binary"...

2019-10-07 11:02:49 276

原创 《笨方法学习python3》练习5: More Variables and Printing

EX5: More Variables and Printing例子:my_name = 'Zed A. Shaw'my_age = 35 # not a liemy_height = 74 # inchesmy_weight = 180 # lbsmy_eyes = 'Blue'my_teeth = 'White'my_hair = 'Brown'print(f"Let'...

2019-10-07 11:00:33 169

原创 《笨方法学习python3》练习4:Variables and Names

EX4: Variables and Names例子:cars = 100space_in_a_car = 4drivers = 30passengers = 90cars_not_driven = cars - driverscars_driven = driverscarpool_capacity = cars_driven * space_in_a_caraverage...

2019-09-23 11:45:33 224

原创 《笨方法学习python3》练习3:Numbers and Math

EX3: Numbers and Math例子:print("I will now count my chickens:")print("Hens",25 + 31 / 6) print("Roosters",100 - 25 * 3 % 4) print("Now I will count the eggs:")print(3 + 2 + 1 - 5 + 4 % 2 -1 ...

2019-09-23 11:39:31 186

原创 《笨方法学习python3》练习2: Comments and Pound Characters

EX2: Comments and Pound Characters例子:# A comment, this is so you can read your program laterself.# Angthing after the # is ignored by python.print("I could have code like this.") # and the comme...

2019-09-23 11:28:56 283

原创 《笨方法学习python3》练习1: A Good First Program

学习内容:print();#;

2019-09-23 11:07:27 386

原创 Javascript 访问对象属性

三种访问对象属性的方法

2016-11-29 22:41:32 397

转载 Javascript 对象字面量与构造函数

对象创建方式对象字面量:这是一种优美的对象创建方式,它以包装在大括号中的逗号分割的键-值(key-value)对的方式创建对象。 构造函数:主要包括内置构造函数(几乎总是有一个更好且更短的字面量表示法)和自定义构造函数。

2016-11-29 22:01:46 938

原创 JavaScript 对象字面量(object literal)

什么是字面量 用来为变量赋值时的常数量 对象字面量 对象字面值是封闭在花括号对({})中的一个对象的零个或多个”属性名:值”列表。var person={ name:"Jack", age:10, 5:true };在这个例子中,左边的花括号({)表示对象字面量的开始,因为它出现在了表达式上下文(expression context)中。JavaScript

2016-11-27 23:14:15 9078

空空如也

空空如也

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

TA关注的人

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