有道笔记-Python基础课程:有道云笔记
python编程10大必备网站
python官网:最全面的学习宝库,有下载,语法,标准库,最新版本和疑难解答。
牛客网:刷题圣地,有面试题和入门练习,轻松在线写代码。
github:代码乐园,藏着python教程,开源项目和技术宝典。
w3school:编程百宝箱,涵盖python和更多领域的知识。
stackoverflow:技术答疑圣地,近200万个python问题等你来解锁。
Kaggle:Kaggle是数据科学和机器学习竞赛平台,有许多实际项目和教程,帮助你应用python解决问题。
Leetcode:Leetcode 是一个优秀的算法练习平台,有丰富的算法题目,帮助你提升编程和解题能力。
DOS命令
D:#进入d盘
dir #查看该路径下的文件
PyCharm代码编写快捷键
序号 快捷键 描述
1 Ctrl+/ 注释选中行
2 Ctrl+Alt+Enter 向上插入
3 Shift+Enter 向下插入
4 Ctrl+D 复制、粘贴一行
5 Ctrl+Y 删除一行
6 Shift+F6 重命名
7 Ctrl+O 复写代码(方法重写)
8 Ctrl+Alt+T 添加 try/catch
9 Ctrl+Alt+M 抽取代码(提取出函数等)
10 Ctrl+Alt+F 变量抽取全局变量(局部变量变属性)
11 Ctrl+Alt+V 方法体内值抽取成变量
12 Shift+Tab 反向退格
13 Tab 进行退格
14 Alt+Shift+上下键 选中代码移动
15 Ctrl+Shift+上下键 移动当前方法体
16 Ctrl+Shift+U 代码大小写
17 Ctrl+Shift+Enter 补全代码
18 Ctrl+B 进入代码
19 Ctrl+Shift+F12 最大化窗口
20 Ctrl+F 查找
21 Ctrl+R 替换
22 Ctrl+Shift+F 全局查找
23 Ctrl+Shift+R 全局替换
24 Ctrl+Shift+I 快捷查看方法实现的内容
25 Ctrl+P 查看参数
26 Ctrl+Q 查看文档描述
27 Shift+F1 查看 API 文档
28 Ctrl+F12 查看类的方法
29 Ctrl+H 查看类的继承关系
30 Ctrl+Alt+H 查看哪里调用了方法
31 Ctrl+{} 定位方法体的括号
32 F3 查看选中的内容
33 Shift+F3 反向查看内容
34 Ctrl+Alt+B 查询类实现光标所在接口的类
35 Ctrl+U 查看父类
36 Ctrl+E 最近编辑的文件列表
37 Ctrl+Alt+Home 查看布局与对应的类
38 Alt+Insert 新建文件及工程
39 Ctrl+Alt+S 打开软件设置
40 Ctrl+Alt+Shift+S 打开 module 设置
41 Ctrl+Tab 切换目录及视频
42 Alt+Shift+C 查看工程最近更改的地方
43 Ctrl+J livetemp 模板查看
44 Ctrl+F9 构建
45 Shift+F10 运行
46 F11 定义书签
47 Shift+F11 查看书签
48 Ctrl+J 快速调出模板
49 Alt+点击断点 禁用断点
50 F2 定位错误
51 Alt+Enter 修正错误
52 Alt+鼠标 进行列编辑模式
53 Ctrl+W 选中单词
54 Ctrl+Alt+左右键 定位到编辑的位置
55 Ctrl+Alt+L 自动调整
三个引号包裹的字符串可以换行,可以加单引号。
变量名不能用Python保留的变量名,如print,但可以修改大小写。
变量
内存中如果存储非常多的数据. 如何进行区分呢? 用变量给每一块内存进行命名. 以后使用的时候就不会混乱了
变量:将运算的中间结果暂存到内存,以便后续程序调用
变量的命名规则:
1, 变量由字母, 数字,下划线搭配组合而成
2, 不可以用数字开头,更不能是全数字
3,不能是Python的关键字, 这些符号和字母已经被Python占用, 不可以更改, 比如, if, while, break, continue等等
4,不要用中文
5,名字要有意义
6,不要太长
7, 区分大小写
推荐大家使用驼峰体或者下划线命名
驼峰体: 除首字母外的其他每个单词首字母大写
下划线: 每个单词之间用下划线分开
常量
有些时候, 我们在内存中定义的数据是不希望别人去随意更改的. 比如. 数据库的用户名和密码. 这种数据是不能随便动的. 像这种只能看, 不能改的数据. 我们一般定义为常量, 但是呢, 在python中不存在绝对的常量. 大家约定俗成, 所有字母大写就是常量。
PI = 3.141592653
BIRTH_OF_SYLAR = 1998
DB_NAME = "ROOT"
DB_PSW = "123456"
注释
有时候我们写的东西不一定都是给用户看的. 或者不希望解释器执行. 那我们可以使用#来注释掉代码. 被注释的内容是不会执行的.可以方便后面的程序员来拜读你的代码
单行注释: # 被注释的内容
多行注释:''' 被注释的内容 ''', """这个也是多行注释”""
# 我们都知道. Sylar是一个dsb. 但是我们从来都不说
"""
今天你们也知道了. 但是记住了,
不能说. 心里默念即可
"""
函数
在代码量很少的时候, 我们并不需要函数. 但是一旦代码量大了. 一次写个几百行代码. 调试起来就很困难. 此时, 建议把程序改写成一个一个具有特定功能的函数. 方便调试. 也方便代码的重用。
def 函数名(形式参数):
# 函数体
return 返回值
上面是编写一个函数的固定逻辑. 但是, 编写好的函数是不会自己运行的. 必须有人调用才可以:
函数名(实际参数)
写一个试试:
def get_page_source(url):
print("我要发送请求了. 我要获取到页面源代码啊")
return "页面源代码"
pg_one = get_page_source("baidu.com")
pg_two = get_page_source("koukou.com")
再来一个:
def download_image(url, save_path):
print(f"我要下载图片{url}了", f"保存在{save_path}")
donwload_image("http://www.baidu.com/abc/huyifei.jpg", "胡二飞.jpg")
donwload_image("http://www.baidu.com/aaa/dagedagefeifeifei.jpg", "大哥大哥飞飞飞.jpg")
总结, 函数的好处就是, 以后需要该功能. 不用再写重复代码了。
常见函数
# len() 函数,显示字符串中字符的个数
len('hello') # 5
len('') # 0
# replace() 替换字符串
字符串.replace('原字符串','新字符串')
# str() 转入一个整数值,并求值为它的字符串形式(方便将整数和字符串连接)
str(29) # '29'
print('I am' + str(29) + 'years old.') # I am 29 years old.
# str() int() float() 函数将分别求值为转入值的字符串、整数和浮点数形式。
# input() 用户输入,返回一个字符串,(输入整数。用int(),转为整数值使用)
# round() 保留3位小数
e = 1.5132131
print(e) # 1.5132131
print(round(e)) # 1.513 保留3位小数 多出原数位的,无法添加0补充位数
# range() 开始、停止和步长参数
for i in range(0,10,2):
print(i)
'''
0
2
4
6
8
'''
'''
函数的概念
函数的参数
函数的返回值
python内置函数( print() len() )
函数:对某一个特定的功能或者代码块进行封装.在需要使用该功能的时候直接调用即可
定义:
def函数的名字():
被封装的功能或者代码块 -> 函数体
调用:
函数的名字()
好处:让程序更加简洁,代码更加合理
参数:可以在函数调用的时候,给函数传递一些信息
分类:
1. 形参,在函数定义的时候。需要准备一些变量来接收信息
1. 位置参数, 按照位置一个一个的去声明变量
2. 默认值参数,在函数声明的时候给变量一个默认值,如果实参不传递信息,此时默认值生效,否则就不生效
3. 动态传参:
1. *args, 表示接受所有的位置参数的动态传参
2. **kwargs, 表示接收所有的关键字的动态传参
**顺序* : 位置 > *args > 默认值 > **kwargs
2. 实参,实际在调用的时候传递的信息
1. 位置参数, 按照位置进行传递参数
2. 关键字参数, 按照参数的名字进行传递参数
3. 混合参数.
顺序: 位置参数放前面,关键字参数放后面 -> 否则报错!官方不让这样干
实参在执行的时候,必须要保障形参有数据
'''
def buy_cai(): # 定义函数
print("1.打车")
print("2.去菜市场")
print("3.讨价还价")
print("4.回家")
buy_cai()
print("哄哄孙子")
buy_cai()
print("1.打车")
# 1.骂谁? 2.骂到什么程度?
def maren(ren, lvl): # 形参
print("1. 怒目而视", ren)
print("2. 验证交涉", ren)
if lvl > 99:
print("3. 死不要脸")
eLse:
print("3. 你愁啥")
print("4. 骂完手工")
maren("破键盘", 188) # 在调用函数的时候,才能知道到底骂谁,骂道什么程度 ——> 实参
maren("破鼠标", 18)
maren("破电脑", 999)
#请用函数编写一个计算器,能计算 + - * /四则运算 a + b
def jisuan(a, opt, b):
if opt == "+":
print(a + b)
elif opt == '-' :
print(a - b)
elif opt == '*' :
print(a * b)
elif opt == '/':
print(a / b)
else :
print("滚犊子")
jisuan(999, "+", 666)
jisuan(999, "-", 666)
jisuan(999, "*", 666)
jisuan(999, "/", 666)
def chi(zhu, fu, tang, tian):
print(zhu, fu, tang, tian)
chi("大米饭","西红柿炒鸡蛋", "紫菜蛋花汤","哈根达斯")
chi(zhu="小米饭", tang="胡辣汤", fu="这地大顺子", tian="老冰棍")
chi("小米饭", "胡辣汤", fu="这地大顺子", tian="老冰棍")
chi() # 实参在执行的时候.必须要保障形参有数据
open("xxxx", mode="xx", encoding="xxx" )
def luru(name, age, gender = "男"): # 顺序 : 位置 > 默认值
print(name, age, gender)
luru("张三", 18)
luru("李四", 18)
luru("王二", 18, "女")
luru("张武", 18, "女")
def chi(*food): # *表示位置参数的动态传参,*接收到的值会被统一放在一个元组里面
print(food)
chi('大米饭',"烧茄子", '紫菜蛋花汤',"哈根达斯")
chi("大米饭" )
chi("大米饭","烧茄子")
chi("大米饭","紫菜蛋花汤" )
chi("大米饭", "紫菜蛋花汤", "紫菜蛋花汤")
def chi(**food): # ** 表示接收关键字的动态传参,接收到的所有参数都会被处理成字典
print(food)
chi(fu="木须柿子", zhu="小米饭")
# 何时能产生默认值
def func(a, b, C="哈哈", *args, **kwargs):
print(a, b, C, args, kwargs)
func(1, 2, 4, 5, 6, 7, 8, 9, hello=456, hahalou =654)
# 1 2 3 (4, 5, 6, 7, 8, 9) {'hello': 456,'hahalou': 654}
func(1, 2, hello=456, hahalou =654) # 1 2 哈哈 () {'hello': 456,'hahalou': 654}
def func(*args, **kwargs): # 没有限制的接收任何参数
print(args, kwargs)
func() # () {}
func(1) # (1, ) , {}
func(1223.4x4, a=2) # (1,2,3,4,4), {"a": 2}
func(1,2,324, c=4, a=2) # (1,2,3,4,4),{"c": 2}, {"a": 2}
stu_lst = ["流川枫",'櫻木', "大老王", "隔壁二老王", "隔壁二老王", "隔壁二老王", "隔壁二老王", "隔壁二老王" ,]
def func(*args):
print(args)
func(*stu_lst) # * 在实参位置,是把列表打散成位置参数进行传递
# ** 在实参位置,可以把宇典自动转化成关键字参数进行传递
关于return
'''
返回值:函数执行之后。会给调用方一个结果. 这个结果就是返回值
关于return:
函数只要执行到了return. 函数就会立即停止并返回内容. 函数内的return的后续的代码不会执行
1.如果函数内没有return, 此时外界收到的是 None
2.如果写了return
1. 只写了return,后面不跟数据,此时接收到的依然是 None --> 相当于 break
2. return值,此时表示函数有一个返回值,外界能够收到一个数据 --> 用到最多
3. return值1, 值2, 值3......, 此时函数有多个返回值,外界收到的是元组,并且,该元组内存放所有的返回值
'''
def func(a, b):
print(a+b)
return a + b
ret = func(10, 20)
def func():
print(123)
return # 程序停止,后续代码不会继续执行,有点从像循环里面的 break
print(456)
ret = func()
print(ret)
内置函数
'''
内置函数:直接能拿来用的函数
print
input
...
截止到python版本3.6.2 ,python一共提供了68个内置函数,具体如下
abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() exec() isinstance() ord() sum()
bytearray() filter() issubclass() pow() super()
bytes() float() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()
delattr() hash() memoryview() set()
'''
# print("hello world")
S = "123"
i = int(s)
b = bool(s)
f = float(s)
# 和数字相关
# 1. 数据类型
bool : # 布尔型(True,False)
int : # 整型(整数)
float : # 浮点型(小数)
complex : # 复数
# 2. 进制转换
bin() # 将给的参数转换成二进制
otc() # 将给的参数转换成八进制
hex() # 将给的参数转换成十六进制
print(bin(10)) # 二进制:0b1010
print(hex(10)) # 十六进制:0xa
print(oct(10)) # 八进制:0o12
# 3. 数学运算
abs() # 返回绝对值
divmode() # 返回商和余数
round() # 四舍五入
pow(a, b) # 求a的b次幂 ( a**b ), 如果有三个参数. 则求完次幂后对第三个数取余
sum() # 求和
min() # 求最小值
max() # 求最大值
print(abs(-2)) # 绝对值:2
print(divmod(20,3)) # 求商和余数:(6,2)
print(round(4.50)) # 五舍六入:4
print(round(4.51)) #5
print(pow(10,2,3)) # 如果给了第三个参数. 表示最后取余:1
print(sum([1,2,3,4,5,6,7,8,9,10])) # 求和:55
print(min(5,3,9,12,7,2)) #求最小值:2
print(max(7,3,15,9,4,13)) #求最大值:15
# 和数据结构相关
# 1. 序列
# (1)列表和元组
list() # 将一个可迭代对象转换成列表
tuple() # 将一个可迭代对象转换成元组
print(list((1,2,3,4,5,6))) #[1, 2, 3, 4, 5, 6]
print(tuple([1,2,3,4,5,6])) #(1, 2, 3, 4, 5, 6)
# (2)相关内置函数
reversed() # 将一个序列翻转, 返回翻转序列的迭代器
slice() # 列表的切片
lst = "你好啊"
it = reversed(lst) # 不会改变原列表. 返回一个迭代器, 设计上的一个规则
print(list(it)) #['啊', '好', '你']
lst = [1, 2, 3, 4, 5, 6, 7]
print(lst[1:3:1]) #[2,3]
s = slice(1, 3, 1) # 切片用的
print(lst[s]) #[2,3]
# (3)字符串
str() # 将数据转化成字符串
print(str(123)+'456') #123456
format() # 与具体数据相关, 用于计算各种小数, 精算等.
s = "hello world!"
print(format(s, "^20")) #剧中
print(format(s, "<20")) #左对齐
print(format(s, ">20")) #右对齐
# hello world!
# hello world!
# hello world!
print(format(3, 'b' )) # 二进制:11
print(format(97, 'c' )) # 转换成unicode字符:a
print(format(11, 'd' )) # ⼗进制:11
print(format(11, 'o' )) # 八进制:13
print(format(11, 'x' )) # 十六进制(⼩写字母):b
print(format(11, 'X' )) # 十六进制(大写字母):B
print(format(11, 'n' )) # 和d⼀样:11
print(format(11)) # 和d⼀样:11
print(format(123456789, 'e' )) # 科学计数法. 默认保留6位小数:1.234568e+08
print(format(123456789, '0.2e' )) # 科学计数法. 保留2位小数(小写):1.23e+08
print(format(123456789, '0.2E' )) # 科学计数法. 保留2位小数(大写):1.23E+08
print(format(1.23456789, 'f' )) # 小数点计数法. 保留6位小数:1.234568
print(format(1.23456789, '0.2f' )) # 小数点计数法. 保留2位小数:1.23
print(format(1.23456789, '0.10f')) # 小数点计数法. 保留10位小数:1.2345678900
print(format(1.23456789e+3, 'F')) # 小数点计数法. 很大的时候输出INF:1234.567890
bytes() # 把字符串转化成bytes类型
bs = bytes("今天吃饭了吗", encoding="utf-8")
print(bs) # b'\xe4\xbb\x8a\xe5\xa4\xa9\xe5\x90\x83\xe9\xa5\xad\xe4\xba\x86\xe5\x90\x97'
bytearray() #返回一个新字节数组. 这个数字的元素是可变的, 并且每个元素的值得范围是[0,256)
ret = bytearray("alex" ,encoding ='utf-8')
print(ret[0]) #97
print(ret) #bytearray(b'alex')
ret[0] = 65 #把65的位置A赋值给ret[0]
print(str(ret)) #bytearray(b'Alex')
ord() # 输入字符找带字符编码的位置
chr() # 输入位置数字找出对应的字符
ascii() # 是ascii码中的返回该值 不是就返回u
b = "中" # python的内存中使用的是 unicode
print(ord('a')) # 字母a在编码表中的码位:97
print(ord('中')) # '中'字在unicode 编码表中的位置:20013
print(chr(65)) # 已知码位,求字符是什么:A
print(chr(19999)) # 丟
print(chr(20013)) #给出编码位置。展示出文字 中
for i in range(65536): #打印出0到65535的字符
print(chr(i), end=" ")
print(ascii("@")) #'@'
repr() 返回一个对象的string形式
s = "今天\n吃了%s顿\t饭" % 3
print(s)#今天# 吃了3顿 饭
print(repr(s)) # 原样输出,过滤掉转义字符 \n \t \r 不管百分号%
#'今天\n吃了3顿\t饭'
# 2. 数据集合
# 字典:dict 创建一个字典
# 集合:set 创建一个集合
frozenset() # 创建一个冻结的集合,冻结的集合不能进行添加和删除操作。
# 3. 相关内置函数
len() # 返回一个对象中的元素的个数
sorted() # 对可迭代对象进行排序操作 (lamda)
# 语法:sorted(lterable, key=函数(排序规则), reverse=False)
lterable: # 可迭代对象
key: # 排序规则(排序函数), 在sorted内部会将可迭代对象中的每一个元素传递给这个函数的参数. 根据函数运算的结果进行排序
reverse: # 是否是倒叙. True: 倒叙, False: 正序
lst = [5,7,6,12,1,13,9,18,5]
lst.sort() # sort是list里面的一个方法
print(lst) #[1, 5, 5, 6, 7, 9, 12, 13, 18]
ll = sorted(lst) # 内置函数. 返回给你一个新列表 新列表是被排序的
print(ll) #[1, 5, 5, 6, 7, 9, 12, 13, 18]
l2 = sorted(lst,reverse=True) # 倒序
print(l2) #[18, 13, 12, 9, 7, 6, 5, 5, 1]
# 根据字符串长度给列表排序
lst = ['one', 'two', 'three', 'four', 'five', 'six']
def f(s):
return len(s)
l1 = sorted(lst, key=f, )
print(l1) # ['one', 'two', 'six', 'four', 'five', 'three']
enumerate() # 获取集合的枚举对象
lst = ['one','two','three','four','five']
for index, el in enumerate(lst,1): # 把索引和元素一起获取,索引默认从0开始. 可以更改
print(index)
print(el)
# 1
# one
# 2
# two
# 3
# three
# 4
# four
# 5
# five
all() # 可迭代对象中全部是True, 结果才是True # 当成and来看 t and t and t
any() # 可迭代对象中有一个是True, 结果就是True # or
print(all([1,'hello',True,9])) # True
print(any([0,0,0,False,1,'good'])) # True
s = "呵呵哒"
print (hash(s)) # 一定是一个数字 -> 想办法转化成内存地址。然后进行数据的存储 -> 字典 (集合)哈希表
# -5810543276956388052
zip() # 函数用于将可迭代的对象作为参数, 将对象中对应的元素打包成一个元组, 然后返回由这些元组组成的列表. 如果各个迭代器的元素个数不一致, 则返回列表长度与最短的对象相同
lst1 = [1, 2, 3, 4, 5, 6]
lst2 = ['醉乡民谣', '驴得水', '放牛班的春天', '美丽人生', '辩护人', '被嫌弃的松子的一生']
lst3 = ['美国', '中国', '法国', '意大利', '韩国', '日本']
print(zip(lst1, lst1, lst3)) #<zip object at 0x00000256CA6C7A88>
for el in zip(lst1, lst2, lst3):
print(el)
# (1, '醉乡民谣', '美国')
# (2, '驴得水', '中国')
# (3, '放牛班的春天', '法国')
# (4, '美丽人生', '意大利')
# (5, '辩护人', '韩国')
# (6, '被嫌弃的松子的一生', '日本')
fiter() # 过滤 (lamda)
# 语法:fiter(function. Iterable)
function: # 用来筛选的函数. 在filter中会自动的把iterable中的元素传递给function. 然后根据function返回的True或者False来判断是否保留留此项数据 , Iterable: 可迭代对象
def func(i): # 判断奇数
return i % 2 == 1
lst = [1,2,3,4,5,6,7,8,9]
l1 = filter(func, lst) #l1是迭代器
print(l1) #<filter object at 0x000001CE3CA98AC8>
print(list(l1)) #[1, 3, 5, 7, 9]
map() # 会根据提供的函数对指定序列列做映射(lamda)
# 语法 : map(function, iterable)
# 可以对可迭代对象中的每一个元素进行映射. 分别去执行 function
def f(i): return i
lst = [1,2,3,4,5,6,7,]
it = map(f, lst) # 把可迭代对象中的每一个元素传递给前面的函数进行处理. 处理的结果会返回成迭代器print(list(it)) #[1, 2, 3, 4, 5, 6, 7]
# 和作用域相关
locals() # 返回当前作用域中的名字
globals() # 返回全局作用域中的名字
def func():
a = 10
print(locals()) # 当前作用域中的内容
print(globals()) # 全局作用域中的内容
print("今天内容很多")
func()
# {'a': 10}
# {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__':
# <_frozen_importlib_external.SourceFileLoader object at 0x0000026F8D566080>,
# '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins'
# (built-in)>, '__file__': 'D:/pycharm/练习/week03/new14.py', '__cached__': None,
# 'func': <function func at 0x0000026F8D6B97B8>}
# 今天内容很多
# 和迭代器生成器相关
range() # 生成数据
next() # 迭代器向下执行一次, 内部实际使⽤用了__ next__()⽅方法返回迭代器的下一个项目
iter() # 获取迭代器, 内部实际使用的是__ iter__()⽅方法来获取迭代器
for i in range(15,-1,-5):
print(i)
# 15
# 10
# 5
# 0
lst = [1,2,3,4,5]
it = iter(lst) # __iter__()获得迭代器
print(it.__next__()) #1
print(next(it)) #2 __next__()
print(next(it)) #3
print(next(it)) #4
# 字符串类型代码执行
eval() # 执行字符串类型的代码. 并返回最终结果
exec() # 执行字符串类型的代码
compile() # 将字符串类型的代码编码. 代码对象能够通过exec语句来执行或者eval()进行求值
s1 = input("请输入a+b:") # 输入:8+9
print(eval(s1)) # 17 可以动态的执行代码. 代码必须有返回值
s2 = "for i in range(5): print(i)"
a = exec(s2) # exec 执行代码不返回任何内容
# 0
# 1
# 2
# 3
# 4
print(a) # None
# 动态执行代码
exec("""
def func():
print(" 我是周杰伦")
""" )
func() #我是周杰伦
code1 = "for i in range(3): print(i)"
com = compile(code1, "", mode="exec") # compile 并不会执行你的代码.只是编译
exec(com) # 执行编译的结果
# 0
# 1
# 2
code2 = "5+6+7"
com2 = compile(code2, "", mode="eval")
print(eval(com2)) # 18
code3 = "name = input('请输入你的名字:')" #输入:hello
com3 = compile(code3, "", mode="single")
exec(com3)
print(name) #hello
# 输入输出
print() : 打印输出
input() : 获取用户输出的内容
print("hello", "world", sep="*", end="@") # sep:打印出的内容用什么连接,end:以什么为结尾
# hello*world@
# 内存相关
hash() : # 获取到对象的哈希值(int, str, bool, tuple). hash算法:(1) 目的是唯一性 (2) dict 查找效率非常高, hash表.用空间换的时间 比较耗费内存
s = 'alex'print(hash(s)) #-168324845050430382lst = [1, 2, 3, 4, 5]print(hash(lst)) #报错,列表是不可哈希的 id() : 获取到对象的内存地址s = 'alex'print(id(s)) #2278345368944
# 文件操作相关
open() : # 用于打开一个文件, 创建一个文件句柄
f = open('file',mode='r',encoding='utf-8')
f.read()
f.close()
# 模块相关
__ import__() : # 用于动态加载类和函数
# 让用户输入一个要导入的模块
import os
name = input("请输入你要导入的模块:")
__import__(name) # 可以动态导入模块
# 帮 助
help() : # 函数用于查看函数或模块用途的详细说明
print(help(str)) #查看字符串的用途
# 调用相关
callable() : # 用于检查一个对象是否是可调用的. 如果返回True, object有可能调用失败, 但如果返回False. 那调用绝对不会成功
a = 10
print(callable(a)) #False 变量a不能被调用
def f():
print("hello")
print(callable(f)) # True 函数是可以被调用的
# 查看内置属性
dir() : # 查看对象的内置属性, 访问的是对象中的__dir__()方法
print(dir(tuple)) #查看元组的方法
'''
函数的嵌套
变量的作用域
闭包
装饰器
迭代器
生成器
推导式
匿名函数
python内置函数_下 , sortef, filter, map,
作用域 : 变量的访问权限
总结:里面访问外面没问题,外面访问里面不能直接访问到
'''
a=10 # 全局变量->全局作用域
print(a)
def func(): # 全局函数
b = 20 # 局部变量,局部作用域
print(a)
print(b) # NameError: name 'b' is not defined
def func():
c = 10086
return C # 如果想要在函数外面访问到函数内部的东西,必须要 return
c1 = func()
print(c1) # 10086
嵌套函数
'''
函数可以嵌套函数
综上:
1, 函数可以作为返回值进行返回
2, 函数可以作为参数进行互相传递
函数名实际上就是一个变量名,都表示一个内存地址
'''
def func1():
pass
def func2():
func1() # 这个叫函数的调用,不叫嵌套
func2()
def func1():
b = 20
def func2(): # 函数的嵌套,局部变量
pass
func2 = def():
print(b)
func2() # 局部的东西,一般都是在局部自己访问使用的
def func():
print (123)
def func2()
print(456)
def.func3():
print(789)
print(1)
func3()
print(2)
print(3)
func2()
print(4)
func1()
'''
123
3
456
1
789
2
4
'''
def func():
def inner():
print(123)
return(inner)
return inner # 返回的是一个函数,此时我们把个函数当成个变量进行返回的
b1 = func() # b1是func的内部inner
print(b1)
b1()
'''
<funct ion func.<locals>. inner at 0x1027aeb90>
<function func. <locals>. inner at 0x1027aeb90>
123
'''
# 代理模式
def func(an): # 此时an收到的是一个函数
an() # 执行这个函数
print(an)
def target():
print("我是target")
c = 456
func(target) # 实参可以是函数
# <function target at 0x10ce9eb90>
'''
global : 在局部,引入全局变量
nonlocal : 在局部,引入外层的局部变量
'''
a =10
def funcQh;
# print(a)
# 此时我就想在函数内部修改全局的变量a
global a # 把外面的全局变量引入到局部
a = 20 #创建一个局部变量,并没有去改变全局变量中的a
func()
print(a)
def func.():
a = 10
def.func2():
nonlocal a # 向外找一层。看看有没有该变量,如果有就引入,如果没有,继续向外一层,直到全局(不包括全局)
a = 20
func2()
print(a)
闭包
'''
闭包: 本质,内层函数对外层函数的局部变量的使用,此时内层函数被称为 闭包函数
1.可以让一个变量常驻与内存
2.可以避免全局变量被修改
'''
def func():
a = 10
def inner()
nonlocal a
a += 1
print(a)
return a
return inner
ret = func()
# inner => ret =>什么时候执行
r1 = ret()
print(r1) # 11
# 1000000
r2 = ret()
print(r2) # 12
内容回顾
'''
内容回顾:
1. 函数可以做为参数进行传递
2. 函数可以作为返回值进行返回
3. 函数名词可以当成变量一样进行赋值操作
装饰器: -> 要求记住最后的结论
修饰器本质上是一个闭包
作用:
在不改变原有函数调用的情况下,给函数增加新的功能.
直白:可以在函数前后添加新功能,但是不改原来的代码
在用户登录的地方,日志。
雏形:
def wrapper(fn): wrapper:装饰器,fn:目标函数
def inner(*args, **kwargs):
#在目标函数执行之前....
ret = fn(*args, **kwargs) # 执行目标函数,# 这里是目标函数的执行,这里是能够拿到从目标函数返回的返回值的。
#在目标函数执行之后....
return ret
return inner # 一定不加()
通用装饰器的写法:
def wrapper(fn): # wrapper:装饰器,fn:目标函数
def inner(*args, **kwargs):
#在目标函数执行之前.....
ret = fn(*args, **kwargs) # 执行目标函数
# 在目标函数执行之后.....
return ret
return inner # 千万别加()
@wrapper
def target():
pass
target() # => inner()
一个函数可以被多个修饰器修饰
规则和规矩:
@wrapper1
@wrapper2
def target():
print('我是目标')
==> wrapper1 wrapper2 TARGET wrapper2 wrapper1
'''
def func():
print('我是函数')
def gggg(fn): # fn要求是个函数
fn() # func()
gggg(func)
def func():
def inner():
print("123")
return inner
ret = func()
ret()
def guanjia(game):
def inner():
print("打开外挂")
game() # 玩起来了
print('关闭外挂')
return inner
@guanjia # 相当于 play_dnf = guanjia(play_dnf)
def play_dnf():
print('你好啊,我叫赛利亚,今天又是美好的一天!')
@guanjia # 相当于 play_lol = guanjia(play_lol)
def play_lol():
print("德玛西亚!!!!!")
play_dnf = guanjia(play_dnf) # 让管家把游戏重新封装一遍。我这边把原来的游戏替换了
play_lol = guanjia(play_lol) # 让管家把lol也封装一下
play_dnf() # 此时运行的是管家给的内层函数inner
print('开挂')
play_dnf()
print('关闭外挂')
rint('开挂')
play_lol()
print('关闭外挂')
def guanjia(game)
def inner(username, password):
print("打开外挂")
game(username, password) # 玩起来了
print('关闭外挂')
return inner
@guanjia # play_dnf = guanjia(play_dnf)
def play_dnf(username, password):
print("我要开始玩儿dnf了. ", username, password)
print('你好啊,我叫赛利亚,今天又是美好的一天!')
def play_dnf(username, password, hero):
print("我要开始玩儿lol了. ", username, password, hero)
print("德玛西亚!!!!!")
def play_lol():
print("德玛西亚!!!!!")
def guanjia(game):
# *,**表示接收所有参数,打包成元组和字典
def inner(*args, **kwargs): # inner添加了参数,args一定是一个元组 kwargs一定是字典 (admin, 123465, 大盖伦)
print("打开外挂" )
# *,** 表示把args元组和kwargs字典打散成位置参数以及关键字参数传递进去
game(*args, **kwargs) # 玩起来了 # game("admin", "123465", "大盖伦")
print('关闭外挂')
return inner
play_dnf("admin", "123465")
play_lol("admin", "456789", "大盖伦")
def wrapperl(fn): # fn: wrapper2.inner
def inner(*args, **kwargs):
print("这里是wrapper1 进入") # 1
ret = fn(*args, **kwargs) # wrapper2.inner
print("这里是wrapper1 出去") # 5
return ret
return inner
def wrapper2(fn): # fn: target
def inner(*args, **kwargs):
print("这里是wrapper2 进入") # 2
ret = fn(*args, **kwargs) # target
print("这里是wrapper2 出去") # 4
return ret
return inner
@wrapper1 # target = wrapper1(wrapper2.inner)
@wrapper2 # target = wrapper2(target) ==> target: wrapper2.inner
def target():
print('我是目标') # 3
target()
'''
这里是wrapper1 进入
这里是wrapper2 进入
我是目标
这里是wrapper2 出去
这里是wrapper1 出去
'''
login_flag = False
def Login_verify(fn):
def inner(*args, **kwargs):
global login_flag
if login_flag == False: # ????
#这里完成登录校验
print("还未完成用户登录操作")
while 1:
username = input(">>>")
password = input(">>>")
if username == "admin" and password == "123":
print("登录成功")
login_flag = True
break
else:
print("登录失败,用户名或密码错误")
ret = fn(*args, **kwargs) # 后续程序的执行
return ret
return inner
@login_verify
def add():
print("添加员工信息")
@login_verify
def delete():
print("删除信息")
@login_verify
def upd():
print("修改信息")
@login_verify
def search():
print( "查询员工信息")
add()
delete()
upd()
search()
'''
匿名函数:
lambda表达式
语法:
变量 = lambda 参数1,参数2,参数3....: 返回值
'''
def func():
print(123456)
return 9999
ret = func()
print(ret)
def func(a, b):
return a + b
ret = func(13, 12)
print(ret)
fn = lambda a, b : a + b
ret = fn(12, 13)
return(ret) # 25
'''
zip : 可以把多个可迭代内容进行合并
locals : 写在了全局作用域范围内。此时看到的就是全局作用域中的内容
此时locals放在局部作用域范围,看到的就是局部作用域的内容
globals : globals看到的是全局作用域中的内容
'''
# 0 1 2
lst1 = ["赵本山", "范伟", '苏有朋']
lst2 = [40, 38, 42]
Lst3 = ["卖拐", "耳朵大有福", "情深深雨蒙蒙"]
result = []
for i in range(len(lst1)):
first = lst1[i]
second = lst2[i]
third = lst3[ i]
result.append((first, second, third))
print(result)
result = zip(lst1, lst2, lst3)
#print(dir(result))
for item in result:
print(item)
lst = list(result)
print(lst)
a = 188
print(locals()) # 此时locals被写在了全局作用域范围内。此时看到的就是全局作用域中的内容
def func():
a = 336
print(locals()) # 此时locals放在局部作用域范围,看到的就是局部作用域的内容
func()
c = 12
print(globals()) # globals看到的是全局作用域中的内容
def func():
a = 336
print(globals()) # globals看到的是全局作用域中的内容
func()
'''
内置函数 sorted : 排序
'''
lst = [16, 22, 68, 1, 147, 256, 49]
s = sorted(lst, reverse=True) # reverse翻转
print(s)
# 1 3 2 4 123132
lst = ["秋", "张二嘎”, "比克", “卡卡罗特", "超级宇宙无敌大帅B"]
def func(item): # item对应的就是列表中的每一项数据
return len(item)
s = sorted(lst, key = lambda x: len(x))
print(s)
lst = [
{"id": 1, "name": "周润发", "age": 18, "salary": 5200},
{"id": 2, "name": "周星驰", "age": 28, "salary": 511100},
{"id": 3, "name": "周海媚", "age": 78, "salary": 561230},
{"id": 4, "name": "周伯通", "age": 12, "salary": 532100},
{"id": 5, "name": "周大兴", "age": 35, "salary": 53210},
{"id": 6, "name": "周周有辣", "age": 47, "salary": 520},
{"id": 7, "name": "周扒皮", "age": 8, "salary": 12},
]
# 1.根据每个人的年龄排序
s = sorted(lst, key = lambda d: d['age'])
print(s)
# 2.根据工资进行排序, 从大到小
s = sorted(lst key=lambda d: d['salary'] reverse=True)
print(s)
'''
filter : 筛选
map : 映射
'''
# T T T F F
lst = ["张无忌", "张三丰", "张翠山", "灭绝小师太", "小狐仙"]
f = filter(lambda x: not x.startswith("张"), lst)
print(list(f))
# ["灭绝小师太", "小狐仙"]
lst = [1,2,3,4,5,6,2,7,8,9]
# result = [item * item for item in lst]
# print(result)
r = map(lambda x: x * x, lst)
print(list(r))
'''
递归:
函数自己调用自己
递归如果没有任何东西拦截的话。它默认就是一个死循环
python默认是有递归深度的限制的,默认的最大递归深度是1000
import sys
print(sys. getrecursionlimit())
sys. getrecursionlimit(2000)
'''
def func():
print(123)
func()
func()
生成器(Generators)
首先我们要理解迭代器(iterators)。根据维基百科,迭代器是一个让程序员可以遍历一个容器(特别是列表)的对象。然而,一个迭代器在遍历并读取一个容器的数据元素时,并不会执行一个迭代。你可能有点晕了,那我们来个慢动作。换句话说这里有三个部分:
- 可迭代对象(Iterable)
- 迭代器(Iterator)
- 迭代(Iteration)
上面这些部分互相联系。我们会先各个击破来讨论他们,然后再讨论生成器(generators)。
可迭代对象(Iterable)
Python中任意的对象,只要它定义了可以返回一个迭代器的 __iter__ 方法,或者定义了可以支持下标索引的 __getitem__ 方法(这些双下划线方法会在其他章节中全面解释),那么它就是一个可迭代对象。简单说,可迭代对象就是能提供迭代器的任意对象。那迭代器又是什么呢?
迭代器(Iterator)
任意对象,只要定义了 next(Python2) 或者 __next__ 方法,它就是一个迭代器。就这么简单。现在我们来理解迭代(iteration)。
迭代(Iteration)
用简单的话讲,它就是从某个地方(比如一个列表)取出一个元素的过程。当我们使用一个循环来遍历某个东西时,这个过程本身就叫迭代。现在既然我们有了这些术语的基本理解,那我们开始理解生成器吧。
生成器(Generators)
生成器也是一种迭代器,但是你只能对其迭代一次。这是因为它们并没有把所有的值存在内存中,而是在运行时生成值。你通过遍历来使用它们,要么用一个 “for” 循环,要么将它们传递给任意可以进行迭代的函数和结构。大多数时候生成器是以函数来实现的。然而,它们并不返回一个值,而是 yield (暂且译作“生出”)一个值。这里有个生成器函数的简单例子:
def generator_function():
for i in range(10):
yield i
for item in generator_function():
print(item)
# Output: 0
# 1
# 2
# 3
# 4
# 5
# 6
# 7
# 8
# 9
这个案例并不是非常实用。生成器最佳应用场景是:你不想同一时间将所有计算出来的大量结果集分配到内存当中,特别是结果集里还包含循环。
译者注:这样做会消耗大量资源
许多 Python 2 里的标准库函数都会返回列表,而 Python 3 都修改成了返回生成器,因为生成器占用更少的资源。
下面是一个计算斐波那契数列的生成器:
# generator version
def fibon(n):
a = b = 1
for i in range(n):
yield a
a, b = b, a + b
函数使用方法如下:
for x in fibon(1000000):
print(x)
用这种方式,我们可以不用担心它会使用大量资源。然而,之前如果我们这样来实现的话:
def fibon(n):
a = b = 1
result = []
for i in range(n):
result.append(a)
a, b = b, a + b
return result
这也许会在计算很大的输入参数时,用尽所有的资源。我们已经讨论过生成器使用一次迭代,但我们并没有测试过。在测试前你需要再知道一个Python内置函数:next()。它允许我们获取一个序列的下一个元素。那我们来验证下我们的理解:
def generator_function():
for i in range(3):
yield i
gen = generator_function()
print(next(gen))
# Output: 0
print(next(gen))
# Output: 1
print(next(gen))
# Output: 2
print(next(gen))
# Output: Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# StopIteration
我们可以看到,在 yield 掉所有的值后,next() 触发了一个 StopIteration 的异常。基本上这个异常告诉我们,所有的值都已经被 yield 完了。你也许会奇怪,为什么我们在使用 for 循环时没有这个异常呢?啊哈,答案很简单。for 循环会自动捕捉到这个异常并停止调用 next()。你知不知道Python中一些内置数据类型也支持迭代哦?我们这就去看看:
my_string = "Yasoob"
next(my_string)
# Output: Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: str object is not an iterator
好吧,这不是我们预期的。这个异常说那个 str 对象不是一个迭代器。对,就是这样!它是一个可迭代对象,而不是一个迭代器。这意味着它支持迭代,但我们不能直接对其进行迭代操作。那我们怎样才能对它实施迭代呢?是时候学习下另一个内置函数,iter。它将根据一个可迭代对象返回一个迭代器对象。这里是我们如何使用它:
my_string = "Yasoob"
my_iter = iter(my_string)
next(my_iter)
# Output: 'Y'
现在好多啦。我肯定你已经爱上了学习生成器。一定要记住,想要完全掌握这个概念,你只有使用它。确保你按照这个模式,并在生成器对你有意义的任何时候都使用它。你绝对不会失望的!
"""
for 变量 in 可迭代:
pass
iterable: 可迭代的东西
iterator: 迭代器
str, list, tuple, dict, set, open()
可迭代的数据类型都会提供一个叫迭代器的东西,这个迭代器可以帮我们把数据类型中的所有数据逐一的拿到
获取迭代器的两种方案:
1. iter() 内置函数可以直接拿到迭代器
2. __iter__() 特殊方法
从迭代器中拿到数据:
1. next() 内置函数
2. __next__() 特殊方法
for里面一定是要拿迭代器的,所以所有不可迭代的东西不能用for循环
for循环里面一定有__next__出现
总结: 迭代器统一了所有不同数据类型的遍历工作
迭代器本身也是可以迭代的
迭代器本身的特性:
1. 只能向前不能反复
2. 特别节省内存
3. 惰性机制
"""
it = iter("你叫什么名字啊")
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it)) # StopIteration: 迭代已经停止了.不可以再次从迭代器中拿数据了
'''
你
叫
什
么
名
字
啊
'''
it = "呵呵哒".__iter__()
print(it.__next__())
print(it.__next__())
print(next(it))
# 模拟for循环工作原理:
s = "我是数据"
it = s.__iter__() # 拿到迭代器
while 1:
try:
data = it.__next__()
print(data) # for循环的循环体
except StopIteration:
break
print(123456)
'''
我
是
数
据
123456
'''
s = "你好啊,我叫赛利亚"
it = s.__iter__()
for mm in it:
print(mm)
'''
你
好
啊
,
我
叫
赛
利
亚
'''
'''
生成器:(generator)
生成器的本质就是迭代器
创建生成器的两种方案:
1.生成器函数
2.生成器表达式
生成器函数
生成器函数中有一个关键字 yield
生成器函数执行的时候,并不会执行函数,得到的是生成器.
'''
def func():
print(123456)
return 999 # yield也有返回的意思.
ret = func()
print(ret) # <generator object func at 0x115f2dbd0>
print(ret.__next__()) # yield只有执行到 next 的时候才会返回数据 # 123456 999
print(ret.__next__()) # StopIteration
ret.__next__() # 123456
'''
yield:只要函数中出现了yield. 它就是一个生成器函数
作用:
1. 可以返回数据
2. 可以分段的执行函数中的内容,通过__next__()可以执行到下一个yield位置
优势:
用好了,特别的节省内存
'''
def func():
print(123)
yield 666
print(456)
yield 999
ret = func()
print(ret.__next__())
print(ret.__next__())
'''
123
666
456
999
'''
# 去工厂定制10000件衣服
def order():
lst = []
for i in range (10000) :
lst.append(f"衣服{i}")
return lst
lst = arder()
print(lst)
def order(:
lst = []
for i in range(10000):
lst.append(f"衣服{i}")
if len(lst) == 50:
yield lst
#下一次拿数据
lst = []
gen = arder()
print(gen.__next__())
print(gen.__next__())
'''
推导式:
简化代码.
语法:
列表推导式: [数据 for循环 if判断]
集合推导式: {数据 for循环 if判断}
字典推导式: {k:v for循环 if判断}
元组推导式???? (数据 for循环 if判断) -> 不是元组推导式,根本就没有元组推导式, 这玩意叫生成器表达式
不要把推导式妖魔化。
'''
lst = []
for i in range(10):
lst.append(i)
print(lst)
'''
lst = [for i in range(10)]
print(lst)
'''
# 1.请创建一个列表[1,3,5,7,9]
lst = [i for i in range(1, 10, 2)]
lst = [i for i in range(10) if i % 2 == 0]
print(lst)
# 2.生成50件衣服
lst = [f"衣服{1}" for i in range(50)]
print(lst)
# 3.将如下列表中所有的英文字母修改成大写
lst1 = ["allen", "tony", "kevin", "sylar"]
lst2 = [item.upper() for item in lst1]
print(lst2)
s ={i for i in range(10)}
print(s)
4.请将下列的列表修改成字典,要求索引做为key,数据作为value
lst = ['赵本山', "潘长江", "高达", "奥特曼"]
dic = {i:lst[i] for i in range(len(lst))}
print(dic)
'''
生成器表达式
语法:(数据 for循环 if)
一次性的
'''
gen = (1**2 for i in range(10))
# print(gen.__next__())
# print(gen.__next__())
# print(gen.__next__())
# print(gen.__next__())
for item in gen:
print(item) # 迭代
lst = list(gen)
print(lst) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
s = list("周杰伦") # list() => for => next()
print(s) # ['周', '杰', '伦']
字符串格式化
#向一个字符串中插入内容
'含有%s的字符串'%'要插入的字符串'
'含有{}的字符串'.format('要插入的字符串')
+操作符 只能加两个整数或两个字符串,不能让一个整数和一个字符串相加。
切片
a = 'asdfghjk'
print = (a[0:4]) # 包前不包后
print = (a[-3:]) # 后三位
数据结构
列表[数据1, 数据2, 数据3, 数据4] 可以存入任何数据,可以增加删除
字典{'数据1': 数据1的值, '数据2': 数据2的值}
元组(数据1, 数据2, 数据3, 数据4) 可以存入任何数据,不可以修改
集合{数据1, 数据2, 数据3, 数据4}
a = 1
a_list = ['a', 'b', a, 2, 3, ['a', 'b', ['z']], ('m', 'n')]
print(a_list[5][2]) # ['z']
print(a_list[5][2][0]) # z
列表的增删
列表.append(增加的内容) #添加到尾部
列表.remove(删除的内容) #删除从左往右数的第一个值,而后面相同的没有删除
补充-Excel与Python
1 读写 用必备利器 xlrd + xlwt 读写 Excel
查看excel表格方法:
R1C1引用样式(使行和列都使用数字)
import xlrd
xlsx = x1rd.open_workbook('d:/7月下旬入库表.xlsx') #读excel文件
table = xlsx.sheet_by_index(0) # 0 为表序名
# table = xsx.sheet_by_name("7月下旬入库表") # 表名
print(table.ce1l_value(1, 2)) # 陕西
print(table.ce11(1, 2).value) # 陕西
print(table.row(1)[2].value) # 陕西
import xlwt # pip install xlwt
new_workbook = xlwt.Workbook() #新建excel
worksheet = new_workbook.add_sheet('new_test') # 新建表
worksheet.write(0, 0,'test' ) # (s行, 列, '内容') 写入值
new_workbook.save('d:/test.xls') # (保存位置) 保存并关闭
2 格式 用神奇的 xlutils 套用 Excel 格式
from xlutils.copy import copy
import xlrd
import xlwt
tem_excel = xlrd.open_workbook( 'D:/日统计.xls', formatting_info=True)
# 'D:/日统计.xls -> 模板位置'
#一定要存为xls格式
tem_sheet = tem_excel.sheet_by_index(0)
new_excel = copy(tem_excel)
new_sheet = new_excel.get_sheet(0)
'''
#直接原格式填写
new_sheet.write(2, 1, 12) # (行, 列, 内容)
new_sheet.write(3, 1, 18)
new_sheet.write(4, 1, 19)
new_sheet.write(5, 1, 15)
new_excel.save('D:/填写.xls')
'''
font = xlwt.Font( ) # 设置格式
font.name = '微软雅黑'
font.bold = True
font.height = 360 # 字号18,要×20 =360
style.font = font # 字体
borders = xlwt.Borders() #边框
borders.top = xlwt.Borders.ThIN
borders.bottom = xlwt.Borders.ThIN
borders.left = xlwt.Borders.THIN
borders.right = xlwt.Borders.ThIN
style.borders = borders
alignment = xlwt.Alignment( ) #对齐
alignment.horz = xlwt.Alignment.HORZ_CENTER
alignment.vent = xlwt.Alignment.VERT_CENTER
style.alignment = alignment
new_sheet.write(2, 1, 12,style) # (行, 列, 内容, 样式名)
new_sheet.write(2, 1, 12,style)
new_sheet.write(3, 1, 18,style)
new_sheet.write(4, 1, 19,style)
new_sheet.write(5, 1, 15,style)
new_excel.save('D:/填写.xls') # 保存
1. Python的动态类型介绍
Python提供了几种方法来查看对象的属性以及详细信息:
dir(x):查看x所指对象的属性
help(x.attr):查看x所指对象的attr属性
help(x):查看x所指对象的详细信息
None
None 对象是一个特殊的Python对象,它总是False,一般用于占位。它有一块内存,是一个真正的对象。它不代表未定义,事实上它有定义。None是所有函数和方法的默认返回值。
2. 基本数据类型
Floor除法 x//y ,它会将结果向下取整到不大于它的最大整数(即使是浮点的Floor除法,结果也是取整的浮点数)
将字符串转为整数除了用 int() 函数外,也可以通过 eval() 函数将字符串转为整数;
整数转字符串除了用 str()/hex() 等函数外,也可以用格式化字符串。
1. Python支持将整数当作二进制位串对待的位操作。
1 整数(int)
在python3中所有的整数都是int类型. 用于计算或者大小的比较
整数能做什么操作:
1. 加减乘除.
+, -, *, /, %, //
前四个不说了. 计算余数. 小学生都知道10除以3等于3余1. 这里的余数就是1. 它能做什么呢? 最主要的就是能判断xxx是否可以被xxx整除. 所谓整除就是没有余数或者余数为零.
a = 10
b = 3
print(a%b) # 计算余数. 1
print(a%b == 0) # 判断有没有余数, 余数如果是0 代表整除. 数学上管这玩意叫 a是b的公倍数
2. 比较大小. > < >= <= == !=
a = 10
b = 30
print(a < b) # 真
print(a > b) # 假
print(a == b) # 假
2 字符串(str)
在Python中,凡是用引号引起来的,全是字符串.
字符串可以用单引号,双引号,或者三引号引起来,没有什么区别,只是一些特殊的格式需要不用的引号比如:
msg = """
今天我想写首小诗,
歌颂我的同桌,
你看他那乌黑的短发,
好像一只炸毛鸡。
"""
数字类型有 +-*/ 字符串有么?
字符串只有 +和 *
#字符串的拼接
s1 = 'a '
s2 = 'bc'
print(s1 + s2)
#相乘 str*int
name = '坚强'
print(name*8)
1 切片和索引
1 索引
索引就是下标, 切记, 下标从0开始
# 0123456 7 8
s1 = "python最牛B"
print(s1[0]) # 获取第0个
print(s1[1])
print(s1[2])
print(s1[3])
print(s1[4])
print(s1[5])
print(s1[6])
print(s1[7])
print(s1[8])
# print(s1[9]) # 没有9, 越界了. 会报错
print(s1[-1]) # -1 表示倒数.
print(s1[-2]) # 倒数第二个
2 切片
我们可以使用下标来截取部分字符串的内容
基本语法: str[start: end]
规则: 顾头不顾尾, 从start开始截取. 截取到end位置. 但不包括end
s2 = "python最牛B"
print(s2[0:3]) # 从0获取到3. 不包含3. 结果: pyt
print(s2[6:8]) # 结果 最牛
print(s2[6:9]) # 最大是8. 但根据顾头不顾腚, 想要取到8必须给9
print(s2[6:10]) # 如果右边已经过了最大值. 相当于获取到最后
print(s2[4:]) # 如果想获取到最后. 那么最后一个值可以不给.
print(s2[-1:-5]) # 从-1 获取到 -5 这样是获取不到任何结果的. 从-1向右数. 你怎么数也数不到-5
print(s2[-5:-1]) # 牛b, 取到数据了. 但是. 顾头不顾腚. 怎么取最后一个呢?
print(s2[-5:]) # 什么都不写就是最后了
print(s2[:-1]) # 这个是取到倒数第一个
print(s2[:]) # 原样输出
跳着截取
# 跳着取, 步长
print(s2[1:5:2]) # 从第一个开始取, 取到第5个,每2个取1个, 结果: yh, 分析: 1:5=> ytho => yh
print(s2[:5:2]) # 从头开始到第五个. 每两个取一个
print(s2[4::2]) # 从4开始取到最后. 每两个取一个
print(s2[-5::2]) # 从-5取到最后.每两个取一个
print(s2[-1:-5]) # -1:-5什么都没有. 因为是从左往右获取的.
print(s2[-1:-5:-1]) # 步长是-1. 这时就从右往左取值了
print(s2[-5::-3]) # 从倒数第5个开始. 到最开始. 每3个取一个, 结果oy
步长: 如果是整数, 则从左往右取. 如果是负数. 则从右往左取. 默认是1
切片完整语法:
str[start:end:step]
start: 起始位置
end: 结束位置
step: 步长
2 字符串的相关操作方法(记结论)
切记, 字符串是不可变的对象, 所以任何操作对原字符串是不会有任何影响的
1. 大小写转来转去
s1.capitalize()
print(s1) # 输出发现并没有任何的变化. 因为这里的字符串本身是不会发生改变的. 需要我们重新获取
ret1 = s1.capitalize()
print(ret1)
# 大小写的转换
ret = s1.lower() # 全部转换成小写
print(ret)
ret = s1.upper() # 全部转换成大写
print(ret)
# 应用, 校验用户输入的验证码是否合法
verify_code = "abDe"
user_verify_code = input("请输入验证码:")
if verify_code.upper() == user_verify_code.upper():
print("验证成功")
else:
print("验证失败")
ret = s1.swapcase() # 大小写互相转换
print(ret)
# 不常用
ret = s1.casefold() # 转换成小写, 和lower的区别: lower()对某些字符支持不够好. casefold()对所有字母都有效. 比如东欧的一些字母
print(ret)
s2 = "БBß" # 俄美德
print(s2)
print(s2.lower())
print(s2.casefold())
# 每个被特殊字符隔开的字母首字母大写
s3 = "sylar chuchu,baoheizi*展昭_麻花藤"
ret = s3.title() # Sylar chuchu,baoheizi*展昭_麻花藤
print(ret)
# 中文也算是特殊字符
s4 = "sylar最喜欢heihei_bao" # Sylar最喜欢Heihei_Bao
print(s4.title())
2. 切来切去
# 居中
s5 = "周杰伦"
ret = s5.center(10, "*") # 拉长成10, 把原字符串放中间.其余位置补*
print(ret)
# 去空格
s7 = " heihei bao haha "
ret = s7.strip() # 去掉左右两端的空格
print(ret)
ret = s7.lstrip() # 去掉左边空格
print(ret)
ret = s7.rstrip() # 去掉右边空格
print(ret)
# 应用, 模拟用户登录. 忽略用户输入的空格
username = input("请输入用户名:").strip()
password = input("请输入密码: ").strip()
if username == 'ren' and password == '123':
print("登录成功")
else:
print("登录失败")
s7 = "abcdefgabc"
print(s7.strip("abc")) # defg 也可以指定去掉的元素,
# 字符串替换
s8 = "bao_heihei_nezha_huhu"
ret = s8.replace('bao', '包') # 把bao替换成包
print(s8) # bao_heihei_nezha_huhu 切记, 字符串是不可变对象. 所有操作都是产生新字符串返回
print(ret) # 包_heihei_nezha_huhu
ret = s8.replace('i', 'SB', 1) # 把i替换成SB, 替换1个
print(ret) # bao_heSBhei_nezha_huhu
# 字符串切割
s9 = "bao_heihei_nezha_huhu"
lst = s9.split("_") # 字符串切割, 根据_进行切割
print(lst)
lst = ['周杰伦', '王力宏', '麻花藤']
s = "_".join(lst)
print(s) # 周杰伦_王力宏_麻花藤
s10 = """诗人
学者
感叹号
渣渣"""
print(s10.split("\n")) # 用\n切割
# 坑
s11 = "哈哈包黑黑呵呵包黑黑吼吼包黑黑"
lst = s11.split("银王") # ['', '哈哈', '呵呵', '吼吼', ''] 如果切割符在左右两端. 那么一定会出现空字符串.深坑请留意
print(lst)
3. 格式化输出(了解)
# 格式化输出
s12 = "我叫%s, 今年%d岁了, 我喜欢%s" % ('sylar', 18, '周杰伦') # 之前的写法
print(s12)
s12 = "我叫{}, 今年{}岁了, 我喜欢{}".format("周杰伦", 28, "周润发") # 按位置格式化
print(s12)
s12 = "我叫{0}, 今年{2}岁了, 我喜欢{1}".format("周杰伦", "周润发", 28) # 指定位置
print(s12)
s12 = "我叫{name}, 今年{age}岁了, 我喜欢{singer}".format(name="周杰伦", singer="周润发", age=28) # 指定关键字
print(s12)
4. 查找
s13 = "我叫sylar, 我喜欢python, java, c等编程语言."
ret1 = s13.startswith("sylar") # 判断是否以sylar开头
print(ret1)
ret2 = s13.startswith("我叫sylar") # 判断是否以我叫sylar开头
print(ret2)
ret3 = s13.endswith("语言") # 是否以'语言'结尾
print(ret3)
ret4 = s13.endswith("语言.") # 是否以'语言.'结尾
print(ret4)
ret7 = s13.count("a") # 查找"a"出现的次数
print(ret7)
ret5 = s13.find("sylar") # 查找'sylar'出现的位置
print(ret5)
ret6 = s13.find("tory") # 查找'tory'的位置, 如果没有返回-1
print(ret6)
ret7 = s13.find("a", 8, 22) # 切片找
print(ret7)
ret8 = s13.index("sylar") # 求索引位置. 注意. 如果找不到索引. 程序会报错
print(ret8)
5. 条件判断
# 条件判断
s14 = "123.16"
s15 = "abc"
s16 = "_abc!@"
# 是否由数字组成
print(s14.isdigit())
print(s15.isdigit())
print(s16.isdigit())
# 是否由数字组成, 不包括小数点
print(s14.isdigit())
print(s15.isdecimal())
print(s16.isnumeric()) # 这个比较牛B. 中文都识别.
# 练习. 用算法判断某一个字符串是否是小数
s17 = "-123.12"
s17 = s17.replace("-", "") # 替换掉负号
if s17.isdigit():
print("是整数")
else:
if s17.count(".") == 1 and not s17.startswith(".") and not s17.endswith("."):
print("是小数")
else:
print("不是小数")
6. 计算字符串的长度
s18 = "我是你的眼, 我也是a"
ret = len(s18) # 计算字符串的长度
print(ret)
注意: len()是python的内置函数. 所以访问方式也不一样. 你就记着len()和print()一样就行了
7. 迭代
我们可以使用for循环来便利(获取)字符串中的每一个字符
语法:
for 变量 in 可迭代对象:
pass
可迭代对象: 可以一个一个往外取值的对象
s19 = "大家好, 我是VUE, 前端的小朋友们. 你们好么?"
# 用while循环
index = 0
while index < len(s19):
print(s19[index]) # 利用索引切片来完成字符的查找
index = index + 1
# for循环, 把s19中的每一个字符拿出来赋值给前面的c
for c in s19:
print(c)
关于in
'''
in有两种用法:
1. 在for中. 是把每一个元素获取到赋值给前面的变量.
2. 不在for中. 判断xxx是否出现在str中.
'''
print('VUE' in s19)
# 练习, 计算在字符串"I am sylar, I'm 5 years old, I have 2 dogs!"中出现了多少个数字
s20 = "I am sylar, I'm 14 years old, I have 2 dogs!"
count = 0
for c in s20:
if c.isdigit():
count = count + 1
print(count)
结论:
字符串索引和切片
索引从0开始
切片:
s[start: end: step]
start: 起始位置
end: 结束位置, 取不到
step: 步长.
1. upper(), 把字符串中所有的字母都变成大写. 主要使用在忽略大小写的时候用
2. strip(), 默认去掉左右两端的空白, 包括\n, \t, 空格.
3. replace(), 字符串替换
4. split(), 字符串切割. 得到字符串列表
5. join(), 把列表重新组合成字符串
6. startswith(), 判断是否以xxxx开头
7. find(), 查找xxxx
8. count(), 数数, 查看xxx出现的次数
9. isdigit(), 判断该字符串是否是由数字组成
10. len(), 字符串长度, 它是一个内置函数, 直接len(数据)即可
for 变量 in 可迭代对象:
循环体
3 布尔值(bool)
bool类型的取值范围是固定的, 只有真或者假, True和False, 主要作用就是条件判断. 计算机中所有的判断都是由bool值来进行的.
a = 20
b = 30
print(a < b) # 真
print(a > b) # 假
print(a == b) # 假
4 查看数据类型
现在我就给你几个变量. 不告诉你具体的值. 你怎么能知道这几个变量的数据类型呢? python提供了type函数来查看数据类型
a = 10
b = "10"
print(type(a)) # <class 'int'>
print(type(b)) # <class 'str'>
5 用户交互
使用input()函数,可以让我们和计算机互动起来
语法:
内容 = input(提示信息)
这里可以直接获取到用户输入的内容
a = input("请输入一个数字a:")
b = input("请输入一个数字b:")
print(a + b)
此时你会发现结果并不是你想想的那样. 原因是input获取到数据都是str类型的. 此时两个str相加就是字符串拼接.
所以, 我们现在需要把字符串类型的数据转化成int类型
int(str) 把字符串扔进去. 得到的就是数字了. 那么上面的程序就要改成这样
a = int(input("请输入一个数字a:")) # 1
b = int(input("请输入一个数字b:")) # 1
print(a + b) # 2
6 格式化输出
现在有以下需求,让用户输入name, age, job,hobby 然后输出如下所示:
------------ info of Sylar -----------
Name : Sylar
Age : 22
job : Teacher
Hobbie: girl
------------- end -----------------
你怎么实现呢?你会发现,用字符拼接的方式还难实现这种格式的输出,所以一起来学一下新姿势
只需要把要打印的格式先准备好, 由于里面的 一些信息是需要用户输入的,你没办法预设知道,因此可以先放置个占位符,再把字符串里的占位符与外部的变量做个映射关系就好啦。
name = input("Name:")
age = input("Age:")
job = input("Job:")
hobby = input("Hobbie:")
info = '''
------------ info of %s ----------- #这里的每个%s就是一个占位符,本行的代表 后面拓号里的 name
Name : %s #代表 name
Age : %s #代表 age
job : %s #代表 job
Hobbie: %s #代表 hobbie
------------- end -----------------
''' % (name,name,age,job,hobbie) # 这行的 % 号就是 把前面的字符串 与拓号 后面的 变量 关联起来
print(info)
%s就是代表字符串占位符,除此之外,还有%d, 是数字占位符, 如果把上面的age后面的换成%d,就代表你必须只能输入数字啦, 这时对应的数据必须是int类型. 否则程序会报错
使用时,需要进行类型转换.
int(str) # 字符串转换成int
str(int) # int转换成字符串
类似这样的操作在后面还有很多
如果, 你头铁. 就不想转换. 觉着转换很麻烦. 也可以全部都用%s. 因为任何东西都可以直接转换成字符串--> 仅限%s
现在又来新问题了. 如果想输出:
我叫xxx, 今年xx岁了,我们已经学习了2%的python基础了
这里的问题出在哪里呢? 没错2%, 在字符串中如果使用了%s这样的占位符. 那么所有的%都将变成占位符. 我们的2%也变成了占位符. 而"%的"是不存在的, 这里我们需要使用%%来表示字符串中的%.
注意: 如果你的字符串中没有使用过%s,%d站位. 那么不需要考虑这么多. 该%就%.没毛病老铁.
print("我叫%s, 今年22岁了, 学习python2%%了" % '王尼玛') # 有%占位符
print("我叫王尼玛, 今年22岁, 已经凉凉了100%了") # 没有占位符
python3.5以后可以使用f来格式化字符串.
语法 : f"{变量}"
name = "sylar"
print(f"{name}真是一个蠢蠢的小蠢蠢")
7 基本运算符
计算机可以进行的运算有很多种,可不只加减乘除这么简单,运算按种类可分为:
算数运算、比较运算、逻辑运算、赋值运算、成员运算、身份运算、位运算
今天我们暂时学习前面的几个. 后面的身份运算和位运算咱们把它放在后面再讲.
'''
1.算数运算
+ - * / %
2.比较运算
> < >= <= == !=
3.赋值运算
= +=, -=, *=......
a += b
a = a + b
n = 1
sum = 0
while n <= 100:
sum = sum + n # sum += n
n = n + 1 # n += 1
4.逻辑运算
1. and, 并且,左右两端同时成立。结果才能成立
2. or, 或者,左右两端有一个成立,结果就成立
3. not,非,非真既假,非假既真
当and和or以及not同时出现的时候,最好呢。加上括号.不会产生歧义或者不易理解的问题
如果没有括号怎么办?
记住运算顺序:
先算括号 > 算not > and > or
5.成员运算
in 判断xxx是否在xxxx中出现了
not in 判断xxx是否不在xxxx中出现了
'''
# a = 10
# b = 3
# c = a % b # 10 / 3 = 3.....
# d = a // b
# print(c)
# print(d)
# 让用户输入一个数字,判断是否是35的倍数
n = int(input("来个数: "))
if n % 35 == 0:
print("是35的倍数")
eLse:
print("不是35的倍数")
a = 30
b = 40
# #互换操作
#temp=a #备份,有桌子
#a=b
# b=temp
a, b = b, a
print(a) # 40
print(b) # 30
# 逻辑运算
# print(True and True and True and False)
# print(False or True or False or False)
# print( not False)
# 模拟用户登录。
username = input ("用户名:")
password = input ("密码:")
if username == "admin" and password == "123456":
print("登录成功")
else:
print("登录失败")
print(True and False or True and False or not True and True or False) # False
print(False or False or False or False) # False
lst = [1,2,3,4,5,]
print(3 in lst) # True
print(666 not in lst) # True
1 算数运算
以下假设变量:a=10,b=20
2 比较运算
以下假设变量:a=10,b=20
3 赋值运算
以下假设变量:a=10,b=20
4 逻辑运算->重点
逻辑运算的运算顺序: () > not > and > or
综上, 记住, 使用复杂的逻辑运算的时候切记加括号.
逻辑运算符前后有可能是数字. 此时如何进行运算呢? (了解)
x or y , x为真,值就是x, x为假,值是y;
x and y, x为真,值是y, x为假,值是x。
5 成员运算
从名字上也能看出来, 成员运算就是判断xxxx是否在xxxxx中出现了. 比如, 判断一句话中是否包含了"苍"
content = input("请输入你的评论内容:")
if "苍" in content:
print("存在苍")
else:
print("不存在苍")
成员运算还有一个叫 not...in 逻辑和in正好相反. 表示xxxx是否不在xxxx中出现.
例如,
content = input("请输入你的评论内容:")
if "苍" not in content:
print("不存在苍, 该评论合法")
else:
print("存在苍, 该评论不合法")
8 编码的问题(记结论)
ASCII码最多只能表示 256 个符号。
Bin(二进制) | Oct(八进制) | Dec(十进制) | Hex(十六进制) | 缩写/字符 | 解释 |
0000 0000 | 0 | 0 | 00 | NUL(null) | 空字符 |
0000 0001 | 1 | 1 | 01 | SOH(start of headline) | 标题开始 |
0000 0010 | 2 | 2 | 02 | STX (start of text) | 正文开始 |
0000 0011 | 3 | 3 | 03 | ETX (end of text) | 正文结束 |
0000 0100 | 4 | 4 | 04 | EOT (end of transmission) | 传输结束 |
0000 0101 | 5 | 5 | 05 | ENQ (enquiry) | 请求 |
0000 0110 | 6 | 6 | 06 | ACK (acknowledge) | 收到通知 |
0000 0111 | 7 | 7 | 07 | BEL (bell) | 响铃 |
0000 1000 | 10 | 8 | 08 | BS (backspace) | 退格 |
0000 1001 | 11 | 9 | 09 | HT (horizontal tab) | 水平制表符 |
0000 1010 | 12 | 10 | 0A | LF (NL line feed, new line) | 换行键 |
0000 1011 | 13 | 11 | 0B | VT (vertical tab) | 垂直制表符 |
0000 1100 | 14 | 12 | 0C | FF (NP form feed, new page) | 换页键 |
0000 1101 | 15 | 13 | 0D | CR (carriage return) | 回车键 |
0000 1110 | 16 | 14 | 0E | SO (shift out) | 不用切换 |
0000 1111 | 17 | 15 | 0F | SI (shift in) | 启用切换 |
0001 0000 | 20 | 16 | 10 | DLE (data link escape) | 数据链路转义 |
0001 0001 | 21 | 17 | 11 | DC1 (device control 1) | 设备控制1 |
0001 0010 | 22 | 18 | 12 | DC2 (device control 2) | 设备控制2 |
0001 0011 | 23 | 19 | 13 | DC3 (device control 3) | 设备控制3 |
0001 0100 | 24 | 20 | 14 | DC4 (device control 4) | 设备控制4 |
0001 0101 | 25 | 21 | 15 | NAK (negative acknowledge) | 拒绝接收 |
0001 0110 | 26 | 22 | 16 | SYN (synchronous idle) | 同步空闲 |
0001 0111 | 27 | 23 | 17 | ETB (end of trans. block) | 结束传输块 |
0001 1000 | 30 | 24 | 18 | CAN (cancel) | 取消 |
0001 1001 | 31 | 25 | 19 | EM (end of medium) | 媒介结束 |
0001 1010 | 32 | 26 | 1A | SUB (substitute) | 代替 |
0001 1011 | 33 | 27 | 1B | ESC (escape) | 换码(溢出) |
0001 1100 | 34 | 28 | 1C | FS (file separator) | 文件分隔符 |
0001 1101 | 35 | 29 | 1D | GS (group separator) | 分组符 |
0001 1110 | 36 | 30 | 1E | RS (record separator) | 记录分隔符 |
0001 1111 | 37 | 31 | 1F | US (unit separator) | 单元分隔符 |
0010 0000 | 40 | 32 | 20 | (space) | 空格 |
0010 0001 | 41 | 33 | 21 | ! | 叹号 |
0010 0010 | 42 | 34 | 22 | " | 双引号 |
0010 0011 | 43 | 35 | 23 | # | 井号 |
0010 0100 | 44 | 36 | 24 | $ | 美元符 |
0010 0101 | 45 | 37 | 25 | % | 百分号 |
0010 0110 | 46 | 38 | 26 | & | 和号 |
0010 0111 | 47 | 39 | 27 | ' | 闭单引号 |
0010 1000 | 50 | 40 | 28 | ( | 开括号 |
0010 1001 | 51 | 41 | 29 | ) | 闭括号 |
0010 1010 | 52 | 42 | 2A | * | 星号 |
0010 1011 | 53 | 43 | 2B | + | 加号 |
0010 1100 | 54 | 44 | 2C | , | 逗号 |
0010 1101 | 55 | 45 | 2D | - | 减号/破折号 |
0010 1110 | 56 | 46 | 2E | . | 句号 |
00101111 | 57 | 47 | 2F | / | 斜杠 |
00110000 | 60 | 48 | 30 | 0 | 数字0 |
00110001 | 61 | 49 | 31 | 1 | 数字1 |
00110010 | 62 | 50 | 32 | 2 | 数字2 |
00110011 | 63 | 51 | 33 | 3 | 数字3 |
00110100 | 64 | 52 | 34 | 4 | 数字4 |
00110101 | 65 | 53 | 35 | 5 | 数字5 |
00110110 | 66 | 54 | 36 | 6 | 数字6 |
00110111 | 67 | 55 | 37 | 7 | 数字7 |
00111000 | 70 | 56 | 38 | 8 | 数字8 |
00111001 | 71 | 57 | 39 | 9 | 数字9 |
00111010 | 72 | 58 | 3A | : | 冒号 |
00111011 | 73 | 59 | 3B | ; | 分号 |
00111100 | 74 | 60 | 3C | < | 小于 |
00111101 | 75 | 61 | 3D | = | 等号 |
00111110 | 76 | 62 | 3E | > | 大于 |
00111111 | 77 | 63 | 3F | ? | 问号 |
01000000 | 100 | 64 | 40 | @ | 电子邮件符号 |
01000001 | 101 | 65 | 41 | A | 大写字母A |
01000010 | 102 | 66 | 42 | B | 大写字母B |
01000011 | 103 | 67 | 43 | C | 大写字母C |
01000100 | 104 | 68 | 44 | D | 大写字母D |
01000101 | 105 | 69 | 45 | E | 大写字母E |
01000110 | 106 | 70 | 46 | F | 大写字母F |
01000111 | 107 | 71 | 47 | G | 大写字母G |
01001000 | 110 | 72 | 48 | H | 大写字母H |
01001001 | 111 | 73 | 49 | I | 大写字母I |
01001010 | 112 | 74 | 4A | J | 大写字母J |
01001011 | 113 | 75 | 4B | K | 大写字母K |
01001100 | 114 | 76 | 4C | L | 大写字母L |
01001101 | 115 | 77 | 4D | M | 大写字母M |
01001110 | 116 | 78 | 4E | N | 大写字母N |
01001111 | 117 | 79 | 4F | O | 大写字母O |
01010000 | 120 | 80 | 50 | P | 大写字母P |
01010001 | 121 | 81 | 51 | Q | 大写字母Q |
01010010 | 122 | 82 | 52 | R | 大写字母R |
01010011 | 123 | 83 | 53 | S | 大写字母S |
01010100 | 124 | 84 | 54 | T | 大写字母T |
01010101 | 125 | 85 | 55 | U | 大写字母U |
01010110 | 126 | 86 | 56 | V | 大写字母V |
01010111 | 127 | 87 | 57 | W | 大写字母W |
01011000 | 130 | 88 | 58 | X | 大写字母X |
01011001 | 131 | 89 | 59 | Y | 大写字母Y |
01011010 | 132 | 90 | 5A | Z | 大写字母Z |
01011011 | 133 | 91 | 5B | [ | 开方括号 |
01011100 | 134 | 92 | 5C | \ | 反斜杠 |
01011101 | 135 | 93 | 5D | ] | 闭方括号 |
01011110 | 136 | 94 | 5E | ^ | 脱字符 |
01011111 | 137 | 95 | 5F | _ | 下划线 |
01100000 | 140 | 96 | 60 | ` | 开单引号 |
01100001 | 141 | 97 | 61 | a | 小写字母a |
01100010 | 142 | 98 | 62 | b | 小写字母b |
01100011 | 143 | 99 | 63 | c | 小写字母c |
01100100 | 144 | 100 | 64 | d | 小写字母d |
01100101 | 145 | 101 | 65 | e | 小写字母e |
01100110 | 146 | 102 | 66 | f | 小写字母f |
01100111 | 147 | 103 | 67 | g | 小写字母g |
01101000 | 150 | 104 | 68 | h | 小写字母h |
01101001 | 151 | 105 | 69 | i | 小写字母i |
01101010 | 152 | 106 | 6A | j | 小写字母j |
01101011 | 153 | 107 | 6B | k | 小写字母k |
01101100 | 154 | 108 | 6C | l | 小写字母l |
01101101 | 155 | 109 | 6D | m | 小写字母m |
01101110 | 156 | 110 | 6E | n | 小写字母n |
01101111 | 157 | 111 | 6F | o | 小写字母o |
01110000 | 160 | 112 | 70 | p | 小写字母p |
01110001 | 161 | 113 | 71 | q | 小写字母q |
01110010 | 162 | 114 | 72 | r | 小写字母r |
01110011 | 163 | 115 | 73 | s | 小写字母s |
01110100 | 164 | 116 | 74 | t | 小写字母t |
01110101 | 165 | 117 | 75 | u | 小写字母u |
01110110 | 166 | 118 | 76 | v | 小写字母v |
01110111 | 167 | 119 | 77 | w | 小写字母w |
01111000 | 170 | 120 | 78 | x | 小写字母x |
01111001 | 171 | 121 | 79 | y | 小写字母y |
01111010 | 172 | 122 | 7A | z | 小写字母z |
01111011 | 173 | 123 | 7B | { | 开花括号 |
01111100 | 174 | 124 | 7C | | | 垂线 |
01111101 | 175 | 125 | 7D | } | 闭花括号 |
01111110 | 176 | 126 | 7E | ~ | 波浪号 |
01111111 | 177 | 127 | 7F | DEL (delete) | 删除 |
随着计算机的发展. 以及普及率的提高. 流行到欧洲和亚洲. 这时ASCII码就不合适了. 比如: 中文汉字有几万个. 而ASCII最多也就256个位置. 所以ASCII不行了. 怎么办呢? 这时, 不同的国家就提出了不同的编码用来适用于各自的语言环境. 比如, 中国的GBK, GB2312, BIG5, ISO-8859-1等等. 这时各个国家都可以使用计算机了.
GBK, 国标码占用2个字节. 对应ASCII码 GBK直接兼容. 因为计算机底层是用英文写的. 你不支持英文肯定不行. 而英文已经使用了ASCII码. 所以GBK要兼容ASCII.
这里GBK国标码. 前面的ASCII码部分. 由于使用两个字节. 所以对于ASCII码而言. 前几位都是0.
字母A:0100 0001 # ASCII 1kb
字母A:0000 0000 0100 0001 # 国标码 2kb
字母A: 0000 0000 0000 1000 0000 0000 0100 0001 # unicode 4kb
国标码的弊端: 只能中国用. 到了非洲就垮了. 所以国标码不满足我们的使用. 这时提出了一个万国码Unicode. Unicode一开始设计是每个字符两个字节. 设计完了. 发现我大中国汉字依然无法进行编码. 只能进行扩充. 扩充成32位也就是4个字节. 这回够了. 但是. 问题来了. 中国字9万多. 而unicode可以表示41亿多的文字. 根本用不了. 太浪费了. 于是乎, 就提出了新的UTF编码.可变长度编码叫UTF, 我们用的最多的就是UTF-8.
GBK: 每个字符占2个字节, 16位.
UTF-8: 每个字符最少占8位. 每个字符占用的字节数不定.根据文字内容进行具体编码. 比如. 英文. 就一个字节就够了. 汉字占3个字节. 这时即满足了中文. 也满足了节约. 也是目前使用频率最高的一种编码
英文: 1byte, 8bit
欧洲: 2byte, 16bit
中文: 3byte, 24bit
单位转换:
8bit = 1byte
1024byte = 1KB
1024KB = 1MB
1024MB = 1GB
1024GB = 1TB
1024TB = 1PB
1024PB = 1EB
1024EB = 1ZB
1024ZB = 1YB
1024YB = 1NB
1024NB = 1DB
常用到TB就够了。
结论:
1. ascii : 8bit, 主要存放的是英文, 数字, 特殊符号
2. gbk: 16bit, 主要存放中文和亚洲字符. 兼容ascii
3. unicode: 16bit和32bit两个版本. 平时我们用的是16bit这个版本. 全世界所有国家的文字信息. 缺点: 浪费空间(传输和存储)
4. utf-8 : 可变长度unicode, 英文: 8bit, 欧洲文字: 16bit, 中文24bit. 一般数据传输和存储的时候使用.
5. 以上所有编码必须兼容ascii .
2 bytes类型
在python程序中, 当我们的程序运行起来之后. 内存中存储的字符串默认使用的是unicode. 目的是unicode定长. 好处理. 但是, 如果涉及到字符串存储和传输, 就必须要进行编码. 编码成utf-8或者gbk进行传递. 原因是unicode实在是太浪费空间了.
编码: encode()
s = "中国"
bs = s.encode("utf-8")
print(bs) # b'\xe4\xb8\xad\xe5\x9b\xbd'
上例中, 我们看到这样一串特殊的内容b'\xe4\xb8\xad\xe5\x9b\xbd' 这个东西在python中被称为bytes. 我们可以通过type来查看数据类型
print(type(b'\xe4\xb8\xad\xe5\x9b\xbd')) # <class 'bytes'>
这里每一个\x表示一个字节. 数一数就能发现 两个汉字, 对应6个字节. 是符合UTF-8的编码规则的. 那如果编码成GBK呢?
print(s.encode("gbk")) # b'\xd6\xd0\xb9\xfa'
数一数, 4个字节. 也符合gbk的标准.
从上面的结果中我们就能发现, gbk和utf-8是不兼容的. 必须通过程序进行转换. 此时, 我们需要这样做
此时问题来了. 如何把编码之后的bytes转化回我们的字符串?
decode()
bs = b'\xe4\xb8\xad\xe5\x9b\xbd'
s = bs.decode("utf-8") # 只能用utf-8解码
print(s) # 中国
# 重新编码成gbk
bss = s.encode("gbk")
print(bss) # b'\xd6\xd0\xb9\xfa'
总结: 编码用encode() 解码用decode()
9 基础数据类型bool
bool我们已经使用了很长时间了. 它主要的作用就是用来做条件判断, 所以bool类型的变量没有什么操作 这里要给大家聊的是bool类型和其他数据类型之间的转换问题
转换问题:
str => int int(str)
int => str str(int)
int => bool bool(int). 0是False 非0是True
bool=>int int(bool) True是1, False是0
str => bool bool(str) 空字符串是False, 不空是True
bool => str str(bool) 把bool值转换成相应的"值"
# 各种数据类型转化成bool
print(bool(0)) # False
print(bool(1)) # True
print(bool(-1)) # True
print(bool("")) # False
print(bool(" ")) # True
print(bool("哈哈")) # True
print(bool([])) # False
print(bool([1,2,3])) # True
print(bool({})) # False
while 1:
pass
结论: 所有表示空的东西都是False
基本数据类型之间的转化, 想变成谁, 就用谁把数据括起来
10 列表(list)
列表是python的基础数据类型之一 ,其他编程语言也有类似的数据类型. 比如JS中的数组, java中的数组等等. 它是以[ ]括起来, 每个元素用' , '隔开而且可以存放各种数据类型:
列表: 能装东西的东西
lst = [1, '哈哈', "吼吼", [1,8,0,"百度"], ("我","叫", "元", "组"), "abc", {"我叫":"dict字典"},{"我叫集合","集合"}]
列表相比于字符串. 不仅可以存放不同的数据类型. 而且可以存放大量的数据. 32位python可以存放: 536870912个元素, 64位可以存放: 1152921504606846975个元素.而且列表是有序的(按照你保存的顺序),有索引, 可以切片方便取值.
1 列表的索引和切片
列表和字符串一样也拥有索引:
lst = ["麻花藤", "王剑林", "马芸", "周鸿医", "向华强"]
print(lst[0]) # 获取第一个元素
print(lst[1])
print(lst[2])
lst[3] = "流动强" # 注意. 列表是可以发生改变的. 这里和字符串不一样
print(lst) # ['麻花藤', '王剑林', '马芸', '流动强', '向华强']
s0 = "向华强"
s0[1] = "美" # TypeError: 'str' object does not support item assignment 不允许改变
print(s0)
列表的切片:
lst = ["麻花藤", "王剑林", "马芸", "周鸿医", "向华强"]
print(lst[0:3]) # ['麻花藤', '王剑林', '马芸']
print(lst[:3]) # ['麻花藤', '王剑林', '马芸']
print(lst[1::2]) # ['王剑林', '周鸿医'] 也有步长
print(lst[2::-1]) # ['马芸', '王剑林', '麻花藤'] 也可以倒着取
print(lst[-1:-3:-2]) # 倒着带步长
2 列表的相关操作
1. 增加, 注意, list和str是不一样的. list可以发生改变. 所以直接就在原来的对象上进行了操作
lst = ["麻花藤", "林俊杰", "周润发", "周芷若"]
print(lst)
lst.append("wusir")
print(lst)
lst = []
while True:
content = input("请输入你要录入的员工信息, 输入Q退出:")
if content.upper() == 'Q':
break
lst.append(content)
print(lst)
lst = ["麻花藤", "张德忠", "孔德福"]
lst.insert(1, "刘德华") # 在1的位置插入刘德华. 原来的元素向后移动一位
print(lst)
# 迭代添加
lst = ["王志文", "张一山", "苦海无涯"]
lst.extend(["麻花藤", "麻花不疼"])
print(lst)
2. 删除
pop, remove, clear, del
lst = ["麻花藤", "王剑林", "李嘉诚", "王富贵"]
print(lst)
deleted = lst.pop() # 删除最后一个
print("被删除的", deleted)
print(lst)
el = lst.pop(2) # 删除2号元素
print(el)
print(lst)
lst.remove("麻花藤") # 删除指定元素
print(lst)
# lst.remove("哈哈") # 删除不存在的元素会报错
# # print(lst)
lst.clear() # 清空list
print(lst)
# 切片删除
del lst[1:3]
print(lst)
3. 修改
索引切片修改
# 修改
lst = ["得儿得儿", "太牛", "胡辣汤", "王者荣耀", "科科"]
lst[1] = "太污" # 把1号元素修改成太污
print(lst)
lst[1:4:3] = ["麻花藤", "哇靠"] # 切片修改也OK. 如果步长不是1, 要注意. 元素的个数
print(lst)
lst[1:4] = ["压了个嘿嘿龟儿子"] # 如果切片没有步长或者步长是1. 则不用关心个数
print(lst)
4. 查询, 列表是一个可迭代对象, 所以可以进行for循环
for el in lst:
print(el)
5. 其他操作
lst = ["小白", "小黑", "腾哥", "马总", "日天", "小白"]
c = lst.count("小白") # 查询太白出现的次数
print(c)
lst = [1, 11, 22, 2]
lst.sort() # 排序. 默认升序
print(lst)
lst.sort(reverse=True) # 降序
print(lst)
lst = ["小白", "小黑", "腾哥", "马总", "日天", "白天"]
print(lst)
lst.reverse()
print(lst)
l = len(lst) # 列表的长度
print(l)
6. 列表的嵌套, 一层一层的看就好.
lst = [1, "小白", "小黑黑", ["马虎疼", ["可口可乐"], "王剑林"], 'kounijiwa']
# 找到小黑黑
print(lst[2])
# 找到小白和小黑黑
print(lst[1:3])
# 找到小白的白字
print(lst[1][1])
# 将kounijiwa拿到. 然后首字母大写. 再扔回去
s = lst[4]
s = s.capitalize()
lst[4] = s
print(lst)
# 简写
lst[4] = lst[4].capitalize()
print(lst)
# 把小白换成小黑
lst[1] = lst[1].replace("白", "黑")
print(lst)
# 把马虎疼换成马化疼
lst[3][0] = lst[3][0].replace("虎", "化")
print(lst[3][0])
lst[3][1].append("雪碧")
print(lst)
7. range
range可以帮我们获取到一组数据. 通过for循环能分别获取到这些数据
for num in range(10):
print(num)
for num in range(1, 10, 2):
print(num)
for num in range(10, 1, -2): # 反着来, 和切片一样
print(num)
range最大的作用是可以循环出列表中每一个元素的索引
lst = ["周杰伦", "马虎疼", "疼不疼", "傻不傻"]
for i in range(len(lst)):
print(i, lst[i])
总结:
1. append() 增加数据, insert() 插入
2. remove() 删除数据, pop()
3. list[index] = value 修改数据
4. for循环 循环查看
for item in lst:
循环
for i in range(len(lst)):
i
lst[i]
11 元组(tuple)
元组: 俗称不可变的列表.又被成为只读列表, 元组也是python的基本数据类型之一, 用小括号括起来, 里面可以放任何数据类型的数据, 查询可以. 循环也可以. 切片也可以. 但就是不能改.
tu = (1, "太白", "李白", "太黑", "怎么黑")
print(tu)
print(tu[0])
print(tu[2])
print(tu[2:5]) # 切片之后还是元组
# for循环遍历元组
for el in tu:
print(el)
# 尝试修改元组
# tu[1] = "马虎疼" # 报错 'tuple' object does not support item assignment
tu = (1, "哈哈", [], "呵呵")
# tu[2] = ["fdsaf"] # 这么改不行
tu[2].append("麻花藤") # 可以改了. 没报错
tu[2].append("王剑林")
print(tu)
关于不可变, 注意: 这里元组的不可变的意思是子元素不可变. 而子元素内部的子元素是可以变, 这取决于子元素是否是可变对象.
元组中如果只有一个元素. 一定要添加一个逗号, 否则就不是元组
tu = (1,)
print(type(tu))
12 字典(dict)
1 字典的简单介绍
字典(dict)是python中唯一的一个映射类型.他是以{ }括起来的键值对组成. 在dict中key是唯一的. 在保存的时候, 根据key来计算出一个内存地址. 然后将key:value保存在这个地址中. 这种算法被称为hash算法, 所以, 切记, 在dict中存储的key:value中的key'必须是可hash的, 如果你搞不懂什么是可哈希, 暂时可以这样记, 可以改变的都是不可哈希的,
那么可哈希就意味着不可变. 这个是为了能准确的计算内存地址而规定的.
已知的可哈希(不可变)的数据类型: int, str, tuple, bool
不可哈希(可变)的数据类型: list, dict, set
语法 :
{key1: value1, key2: value2....}
注意: key必须是不可变(可哈希)的. value没有要求.可以保存任意类型的数据
# 合法
dic = {123: 456, True: 999, "id": 1, "name": 'sylar', "age": 18, "stu": ['帅哥', '美女'], (1, 2, 3): '麻花藤'}
print(dic[123])
print(dic[True])
print(dic['id'])
print(dic['stu'])
print(dic[(1, 2, 3)])
# 不合法
# dic = {[1, 2, 3]: '周杰伦'} # list是可变的. 不能作为key
# dic = {{1: 2}: "哈哈哈"} # dict是可变的. 不能作为key
dic = {{1, 2, 3}: '呵呵呵'} # set是可变的, 不能作为key
dict保存的数据不是按照我们添加进去的顺序保存的. 是按照hash表的顺序保存的. 而hash表不是连续的. 所以不能进行切片工作. 它只能通过key来获取dict中的数据
2 字典增删改查和其他操作
1. 增加
dic = {}
dic['name'] = '周润发' # 如果dict中没有出现这个key, 就会新增一个key-value的组合进dict
dic['age'] = 18
print(dic)
# 如果dict中没有出现过这个key-value. 可以通过setdefault设置默认值
dic.setdefault('李嘉诚') # 也可以往里面设置值.
dic.setdefault("李嘉诚", "房地产") # 如果dict中已经存在了. 那么setdefault将不会起作用
print(dic)
2. 删除
ret = dic.pop("jay")
print(ret)
del dic["jay"]
print(dic)
# 清空字典中的所有内容
dic.clear()
3. 修改
dic = {"id": 123, "name": 'sylar', "age": 18}
dic1 = {"id": 456, "name": "麻花藤", "ok": "wtf"}
dic.update(dic1) # 把dic1中的内容更新到dic中. 如果key重名. 则修改替换. 如果不存在key, 则新增.
print(dic)
print(dic1)
4. 查询
print(dic['name'])
# print(dic['sylar']) # 报错
print(dic.get("ok"))
print(dic.get("sylar")) # None
print(dic.get("sylar", "牛B")) # 牛B
5. 循环
dic = {"id": 123, "name": 'sylar', "age": 18, "ok": "科比"}
for k in dic:
print(k)
print(dic.keys()) # dict_keys(['id', 'name', 'age', 'ok']) 不用管它是什么.当成list来用就行
for key in dic.keys():
print(key)
print(dic.values()) # dict_values([123, 'sylar', 18, '科比']) 一样. 也当list来用
for value in dic.values():
print(value)
print(dic.items()) # dict_items([('id', 123), ('name', 'sylar'), ('age', 18), ('ok', '科比')]) 这个东西也是list. 只不过list中装的是tuple
for key, value in dic.items(): # ?? 这个是解构
print(key, value)
# 解构
a, b = 1, 2
print(a, b)
(c, d) = 3, 4
print(c, d)
e, f = [1, 2, 3] # 解构的时候注意数量必须匹配
print(e, f)
3 字典的嵌套
# 字典的嵌套
dic1 = {
"name": "汪峰",
"age": 18,
"wife": {
"name": '章子怡',
"age": 28
},
"children": ['第一个毛孩子', '第二个毛孩子'],
"desc": '峰哥不会告我吧. 没关系. 我想上头条的'
}
print(dic1.get("wife").get("name"))
print(dic1.["children"])
print(dic1.get("children")[1])
#首先,字典是以 键值对 的形式进行存储数据的
#字典的表示方式: {key:value, key2:value, key3:value}
dic = {"jay": "周杰伦", "金毛狮王": "谢逊"}
val = dic["金毛狮王"] # 用起来只是把索引换成了key
print(val) # 谢逊
# 字典的 key 必须是可哈希的数据类型
# 字典的 value 可以是任何数据类型
# dic = {[]:123} # 错误
# print(dic)
dic = {"汪峰的孩子": ["孩子1", "孩子2"]}
## 4.2字典的增删改查
dic = dict()
dic['jay'] = "周杰伦"
dic[1] = 123
print(dic)
dic['jay'] ="昆凌" # 此时,字典中已经有了jay. 此时执行的就是修改操作了
print(dic) # {'jay': "昆凌",1: 123}
dic.setdefault("jay", "胡辣汤") # 设置默认值。如果以前已经有了tom了. setdefault就不起作用 了
dic.setdefault("jay", "羊肉泡馍")
print(dic) # {'jay': "胡辣汤",1: 123}
#删除
dic. pop("jay")
print(dic)
##查询
print(dic['jay10010']) # 如果key不存在。程序会报错。当你确定你的key是没问题的,可以用
print(dic.get('jay10086')) # 如果key不存在。程序返回None,当不确定你的key的时候。可以用
# None
a = None # 单纯的就是空,表示没有的意思
print(type(a)) # <class 'NoneType'>
#例子
dic = {
"赵四": "特别能歪嘴",
"刘能": "老,老四啊",
"大脚": "跟这个和那个搞对象",
"大脑袋": "瞎折腾....",
}
name = input ("请输入你想知道的我们村的人的名字: ")
val = dic.get(name)
if val is None:
print("我门村没这个人~~")
else:
print(val)
dic = {
"赵四": "特别能歪嘴",
"刘能": "老,老四啊",
"大脚": "跟这个和那个搞对象",
"大脑袋": "瞎折腾....",
}
# 1.可以用for循环,直接拿到key
for key in dic:
print(key, dic[key])
"""
赵四 特别能歪嘴
刘能 老,老四啊
大脚 跟这个和那个搞对象
大脑袋 瞎折腾....
"""
# 2.希望把所有的key全都保存在一个列表中
print(dic.keys()) # 拿到所有的key了
print(list(dic.keys())) # ['赵四','刘能', '大脚','大脑袋']
# 3.希望吧所有的value都放在一个列表中
print(list(dic.values()))
# 4.直接拿到字典中的key和value
print(list(dic.items()))
for item in dic.items():
key = item[0]
value = item[1]
print(key, value)
"""
赵四 特别能歪嘴
刘能 老,老四啊
大脚 跟这个和那个搞对象
大脑袋 瞎折腾....
"""
# a,b =(1, 2) #元组或者列表 都可以执行该操作。该操作被称为解构(解包)
# print(a)
# print(b)
for key, value in dic.items(): #可以直接拿到字典的所有的key和value
print(item) # 确定,item中只有 两项元素
print(key, value)
"""
赵四 特别能歪嘴
刘能 老,老四啊
大脚 跟这个和那个搞对象
大脑袋 瞎折腾....
"""
# 字典的嵌套
wangfeng = {
'name": "汪峰”
"age": 18,
"wife": {
"name": "章子怡",
"hobby": "演戏",
"assistant": {
"nane": "樵夫",
"age": "19",
"hobby": "打游戏"
}
},
"children": [
{"name": "孩儿1", "age": 13},
{"name": "孩儿2", "age": 10},
{"name": "孩儿3", "age": 8},
]
}
# 汪峰妻子的助手的名字
name = wangfeng['wife']['assistant']['name']
print (name) # 樵夫
# 给汪峰的第二个孩子加1岁
wangfeng['children'][1]['age'] + 1
wangfeng['children'][1]['age'] = wangfeng['children'][1]['age'] + 1
print(wangfeng)
dic = {
"赵四": "特别能歪嘴",
"刘能": "老,老四啊",
"大脚": "跟这个和那个搞对象",
"大脑袋": "瞎折腾....",
}
temp = [] # 存放即将要删除的key
For key in dic:
if key.startswith("大"):
temp.append(key)
# dic.pop(key) # dictionary changed size during iteration
for t in temp: #循环列表,删除字典中的内容
dic.pop(t)
print (dic)
# {'赵四': '特别能歪嘴','刘能': '老,老四啊...'}
get()方法
漂亮打印
13 集合(set)
set集合是python的一个基本数据类型. 一般不是很常用. set中的元素是不重复的.无序的.里面的元素必须是可hash的(int, str, tuple,bool), 我们可以这样来记. set就是dict类型的数据但是不保存value, 只保存key. set也用{}表示
set1 = {'1','周杰伦',2,True,[1,2,3]} # 报错
set2 = {'1','周杰伦',2,True,{1:2}} # 报错
set3 = {'1','周杰伦',2,True,(1,2,[2,3,4])} # 报错
s = {"周杰伦", "周杰伦", "周星星"}
print(s)
结果:
{'周星星', '周杰伦'}
使用这个特性.我们可以使用set来去掉重复
# 给list去重复
lst = [45, 5, "哈哈", 45, '哈哈', 50]
lst = list(set(lst)) # 把list转换成set, 然后再转换回list
print(lst)
最主要的操作: 去重复, 交,并,差
s1 = {"刘能", "赵四", "皮长山"}
s2 = {"刘科长", "冯乡长", "皮长山"}
# 交集
# 两个集合中的共有元素
print(s1 & s2) # {'皮长山'}
print(s1.intersection(s2)) # {'皮长山'}
# 并集
print(s1 | s2) # {'刘科长', '冯乡长', '赵四', '皮长山', '刘能'}
print(s1.union(s2)) # {'刘科长', '冯乡长', '赵四', '皮长山', '刘能'}
# 差集
print(s1 - s2) # {'赵四', '刘能'} 得到第一个中单独存在的
print(s1.difference(s2)) # {'赵四', '刘能'}
# set集合,set集合是无序的
s = {1,"呵呵哒",2,3}
print(type(s))
print(s)
s = {122,3, "呵呵", []} # unhashable type: 'list'
print(s)
#不可哈希: python中的set集合进行数据存储的时候。需要对数据进行哈希计算,根据计算出来的哈希值进行存储数据
# set集合要求存储的数据必须是可以进行哈希计算的。
# 可变的数据类型,list(列表), dict(字典), set(集合)
#可哈希:不可变的数据类型,int, str, tuple 元组, bool 布尔.
S=set() #创建空集合
S.add("赵本山")
s.add ("范伟")
S.add("麻花藤")
print(s) # {'赵本山','范伟','麻花藤'}
s.pop() #由于集合无序。测试的时候没法验证是最后一个。
print(s) # {'范伟','麻花藤'}
s. remove("范伟")
print(s) # {'赵本山','麻花藤'}
# 想要修改。先删除。再新增
S.remove('麻花藤')
S.add('沈腾')
print(s)
#查询
for item in s:
print(item) # 麻花藤 范伟 赵本山
# 交集,并集,差集
s1 = {"刘能","赵四","皮长山"}
s2 = {"刘科长","冯乡长","皮长山"}
print(s1 & s2) #交集
print (s1. intersection(s2)) # {"皮长山"}
print(s1 | s2) #并集
print(s1. union(s2)) # {"刘能","赵四","皮长山","刘科长","冯乡长"}
print(s1 - s2 ) #差集
print(s1. difference(s2)) # {"刘能","赵四"}
# 重要的作用:可以去除重复
s1 = {"周杰伦", "昆凌", "蔡依林", "侯佩岑"}
print(s1)
s1.add("周杰伦")
print(s1)
lst = ["周杰伦", "昆凌", "蔡依林", "侯佩岑", "周杰伦", "昆凌", "蔡依林", "侯佩岑","周杰伦", "昆凌", "蔡依林", "侯佩岑"]
print(lst) # ['周杰伦', '昆凌', '蔡依林', '侯佩岑','周杰伦','昆凌','蔡依林','侯佩岑', '周杰伦','昆凌','蔡依林','侯佩岑']
print(set(lst)) # {'周杰伦' '侯佩岑', '昆凌', '蔡依林'}
print(list(set(lst))) # ['周杰伦' '侯佩岑', '昆凌', '蔡依林']
#去除重复之后的数据是无序的。
set(集合)数据结构
set(集合)是一个非常有用的数据结构。它与列表(list)的行为类似,区别在于 set 不能包含重复的值。
这在很多情况下非常有用。例如你可能想检查列表中是否包含重复的元素,你有两个选择,第一个需要使用 for 循环,就像这样:
some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
duplicates = []
for value in some_list:
if some_list.count(value) > 1:
if value not in duplicates:
duplicates.append(value)
print(duplicates)
### 输出: ['b', 'n']
但还有一种更简单更优雅的解决方案,那就是使用集合(sets),你直接这样做:
some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
duplicates = set([x for x in some_list if some_list.count(x) > 1])
print(duplicates)
### 输出: set(['b', 'n'])
集合还有一些其它方法,下面我们介绍其中一部分。
交集(intersection)
你可以对比两个集合的交集(两个集合中都有的数据),如下:
valid = set(['yellow', 'red', 'blue', 'green', 'black'])
input_set = set(['red', 'brown'])
print(input_set.intersection(valid))
### 输出: set(['red'])
差集(difference)
你可以用差集找出无效的数据,相当于用一个集合减去另一个集合的数据,例如:
valid = set(['yellow', 'red', 'blue', 'green', 'black'])
input_set = set(['red', 'brown'])
print(input_set.difference(valid))
### 输出: set(['brown'])
你也可以用{}符号来创建集合,如:
a_set = {'red', 'blue', 'green'}
print(type(a_set))
### 输出: <type 'set'>
集合还有一些其它方法,我会建议访问官方文档并做个快速阅读。
14 深浅copy
lst1 = ["金毛狮王", "紫衫龙王", "白眉鹰王", "青翼蝠王"]
lst2 = lst1
print(lst1)
print(lst2)
lst1.append("杨逍")
print(lst1)
print(lst2)
结果:
['金毛狮王', '紫衫龙王', '白眉鹰王', '青翼蝠王', '杨逍']
['金毛狮王', '紫衫龙王', '白眉鹰王', '青翼蝠王', '杨逍']
dic1 = {"id": 123, "name": "谢逊"}
dic2 = dic1
print(dic1) # {'id': 123, 'name': '谢逊'}
print(dic2) # {'id': 123, 'name': '谢逊'}
dic1['name'] = "范瑶"
print(dic1) # {'id': 123, 'name': '范瑶'}
print(dic2) # {'id': 123, 'name': '范瑶'}
对于list, set, dict来说, 直接赋值. 其实是把内存地址交给变量. 并不是复制一份内容. 所以. lst1的内存指向和lst2是一样的. lst1改变了, lst2也发生了改变。
1 浅拷贝
lst1 = ["何炅", "杜海涛","周渝民"]
lst2 = lst1.copy()
lst1.append("李嘉诚")
print(lst1)
print(lst2)
print(id(lst1), id(lst2))
结果:
两个lst完全不一样. 内存地址和内容也不一样. 发现实现了内存的拷贝
lst1 = ["何炅", "杜海涛","周渝民", ["麻花藤", "马芸", "周笔畅"]]
lst2 = lst1.copy()
lst1[3].append("无敌是多磨寂寞")
print(lst1)
print(lst2)
print(id(lst1[3]), id(lst2[3]))
结果:
['何炅', '杜海涛', '周渝民', ['麻花藤', '马芸', '周笔畅', '无敌是多磨寂寞']]
['何炅', '杜海涛', '周渝民', ['麻花藤', '马芸', '周笔畅', '无敌是多磨寂寞']]
4417248328 4417248328
浅拷贝. 只会拷贝第一层. 第二层的内容不会拷贝. 所以被称为浅拷贝
2 深拷贝
import copy
lst1 = ["何炅", "杜海涛","周渝民", ["麻花藤", "马芸", "周笔畅"]]
lst2 = copy.deepcopy(lst1)
lst1[3].append("无敌是多磨寂寞")
print(lst1)
print(lst2)
print(id(lst1[3]), id(lst2[3]))
结果:
['何炅', '杜海涛', '周渝民', ['麻花藤', '马芸', '周笔畅', '无敌是多磨寂寞']]
['何炅', '杜海涛', '周渝民', ['麻花藤', '马芸', '周笔畅']]
4447221448 4447233800
都不一样了. 深度拷贝. 把元素内部的元素完全进行拷贝复制. 不会产生一个改变另一个跟着改变的问题。
deepcopy()函数将同时复制它们内部的列表。
15 知识点补充
1. 列表和字典循环的时候不能删除
先看一段代码
lst = ["张无忌", "张翠山", "灭绝师太", "胡辣汤"]
for name in lst:
if name.startswith("张"):
lst.remove(name)
print(lst) # ["张翠山", "灭绝师太", "胡辣汤"]
为什么会这样呢? 原因是: 当删除掉第一个元素之后. 后面的元素就向前移动了一次. 而for循环还要向后走一次. 完美错过了"张翠山"这个元素. 那怎么办呢? 我们需要把要删除的内容先保存在一个新列表中, 然后循环这个新列表. 去删除原来的数据列表
lst = ["张无忌", "张翠山", "灭绝师太", "胡辣汤"]
new_lst = []
for name in lst:
if name.startswith("张"):
new_lst.append(name)
for name in new_lst:
lst.remove(name)
print(lst) # ["灭绝师太", "胡辣汤"]
这样删除就没有问题了
结论: python中的列表和字典在循环的时候. 不能删除自身中的元素. 列表虽然不报错. 但是删不干净. 对于字典, 直接报错. 不让删. 解决方案都一样, 把要删除的内容保存在一个新列表中, 循环新列表, 删除老列表.
2. is和==的区别
a = [1, 2, 3]
b = [1, 2, 3]
print(a == b) # True
print(a is b) # False
结论:
== 判断的是内容. ==> 两个人长的是不是一样?
is 判断的是内存地址. ==> 两个人是不是同一个人
此结论不适合字符串. 这里涉及到小数据池的内容. 不用纠结. 暂时咱们先不用了解小数据池. 只需知道is和==的区别就好
3 while...else
while 条件:
循环体
else: 循环在正常情况跳出之后会执行这里
index = 1
while index < 11:
if index == 8:
# break
pass
else:
print(index)
index = index+1
else:
print("你好")
注意: 如果循环是通过break退出的. 那么while后面的else将不会被执行, 只有在while条件判断是假的时候才会执行这个else
i = 0
while i < 10:
if i == 7:
break
print(i)
else:
print("么么哒") # 这句话不会被打印, 因为i数到7, 就会break. break的是while...else这个整体.
pass: 不表示任何内容. 为了代码的完整性. 占位而已
16 文件操作
os.makedirs()创建新文件夹
python中. 想要处理一个文件. 必须用open()先打开一个文件
语法规则
f = open(文件名, mode="模式", encoding='文件编码')
f.read()|f.write()
f.close()
文件名就不解释了.
模式:
我们需要知道的主要有4个. 分别是: r, w, a, b
- r 只读模式. 含义是, 当前这一次open的目的是读取数据. 所以, 只能读. 不能写
- w 只写模式. 含义是, 当前这一次open的目的是写入数据. 所以, 只能写, 不能读
- a 追加模式. 含义是, 当前这一次open的目的是向后追加. 所以, 只能写, 不能读
- b 字节模式. 可以和上面三种模式进行混合搭配. 目的是. 写入的内容或读取的内容是字节.
问:
- 如果我想保存一张图片. 应该用哪种模式?
- 我想读取txt文件, 用哪种模式?
- 我想复制一个文件. 应该用哪种模式?
encoding: 文件编码. 只有处理的文件是文本的时候才能使用. 并且mode不可以是b
. 99%的时候我们用的是utf-8
另一种写法:
with open(文件名, mode=模式, encoding=编码) as f:
pass
这种写法的好处是, 不需要我们手动去关闭f
读取一个文本文件:
with open("躺尸一摆手.txt", mode="r", encoding="utf-8") as f:
for line in f: # for循环可以逐行的进行循环文件中的内容
print(line)
1. 初识文件操作
使用python来读写文件是非常简单的操作. 我们使用open()函数来打开一个文件, 获取到文件句柄. 然后通过文件句柄就可以进行各种各样的操作了. 根据打开方式的不同能够执行的操作也会有相应的差异.
打开文件的方式: r, w, a, r+, w+, a+, rb, wb, ab, r+b, w+b, a+b 默认使用的是r(只读)模式
2. 只读操作(r, rb)
f = open("护士少妇嫩模.txt",mode="r", encoding="utf-8")
content = f.read()
print(content)
f.close()
需要注意encoding表示编码集. 根据文件的实际保存编码进行获取数据, 对于我们而言. 更多的是utf-8.
rb. 读取出来的数据是bytes类型, 在rb模式下. 不能选择encoding字符集.
f = open("护士少妇嫩模.txt",mode="rb" )
content = f.read()
print(content)
f.close()
结果:
b'\xe6\xaf\x85\xe5\x93\xa5, \xe5\xa4\xaa\xe7\x99\xbd, wuse\n\xe5\x91\xb5\xe5\x91\xb5\n\xe6\x97\xa5\xe5\xa4\xa9'
rb的作用: 在读取非文本文件的时候. 比如读取MP3. 图像. 视频等信息的时候就需要用到rb. 因为这种数据是没办法直接显示出来的. 在后面我们文件上传下载的时候还会用到. 还有. 我们看的直播. 实际上都是这种数据.
绝对路径和相对路径:
- 绝对路径:从磁盘根目录开始一直到文件名.
- 相对路径:同一个文件夹下的文件. 相对于当前这个程序所在的文件夹而言. 如果在同一个文件夹中. 则相对路径就是这个文件名. 如果在上一层文件夹. 则要../
我们更推荐大家使用相对路径. 因为在我们把程序拷贝给别人使用的时候. 直接把项目拷贝走就能运行. 但是如果用绝对路径. 那还需要拷贝外部的文件.
读取文件的方法:
- read() 将文件中的内容全部读取出来. 弊端: 占内存. 如果文件过大.容易导致内存崩溃
f = open("../def/哇擦.txt", mode="r", encoding="utf-8")
content = f.read()
print(content)
结果:
友谊地久天长,
爱一点,
可惜我是水瓶座
一生中最爱
2. read(n) 读取n个字符. 需要注意的是. 如果再次读取. 那么会在当前位置继续去读而不是从头读, 如果使用的是rb模式. 则读取出来的是n个字节
f = open("../def/哇擦.txt", mode="r" encoding="utf-8")
content = f.read(3)
print(content)
结果:
友谊地
f = open("../def/哇擦.txt", mode="rb")
content = f.read(3)
print(content)
结果:
b'\xe5\x8f\x8b'
f = open("../def/哇擦.txt", mode="r", encoding="utf-8")
content = f.read(3)
content2 = f.read(3)
print(content)
print(content2)
结果:
友谊地
久天长
3. readline() 一次读取一行数据, 注意: readline()结尾, 注意每次读取出来的数据都会有一个\n 所以呢. 需要我们使用strip()方法来去掉\n或者空格
f = open("../def/哇擦.txt", mode="r", encoding="utf-8")
content = f.readline()
content2 = f.readline()
content3 = f.readline()
content4 = f.readline()
content5 = f.readline()
content6 = f.readline()
print(content)
print(content2)
print(content3)
print(content4)
print(content5)
print(content6)
结果:
友谊地久天长,
爱一点,
可惜我是水瓶座
一生中最爱
4. readlines()将每一行形成一个元素, 放到一个列表中. 将所有的内容都读取出来. 所以也是. 容易出现内存崩溃的问题.不推荐使用
f = open("../def/哇擦.txt", mode="r", encoding="utf-8")
lst = f.readlines()
print(lst)
for line in lst:
print(line.strip())
5. 循环读取. 这种方式是组好的. 每次读取一行内容.不会产生内存溢出的问题.
f = open("../def/哇擦.txt", mode="r", encoding="utf-8")
for line in f:
print(line.strip())
f.close()
注意: 读取完的文件句柄一定要关闭 f.close()
3. 写模式(w, wb)
写的时候注意. 如果没有文件. 则会创建文件, 如果文件存在. 则将原件中原来的内容删除, 再写入新内容
f = open("小娃娃", mode="w", encoding="utf-8")
f.write("金毛狮王")
f.flush() # 刷新. 养成好习惯
f.close()
wb模式下. 可以不指定打开文件的编码. 但是在写文件的时候必须将字符串转化成utf-8的bytes数据
f = open("小娃娃", mode="wb")
f.write("金毛狮王".encode("utf-8"))
f.flush()
f.close()
4. 追加(a, ab)
只要是a或者ab, a+ 都是在文件的末尾写入. 不论光标在任何位置.
在追加模式下. 我们写入的内容会追加在文件的结尾.
f = open("小娃娃", mode="a", encoding="utf-8")
f.write("麻花藤的最爱")
f.flush()
f.close()
5. 读写模式(r+, r+b)
对于读写模式. 必须是先读. 因为默认光标是在开头的. 准备读取的. 当读完了之后再进行写入. 我们以后使用频率最高的模式就是r+
正确操作是:
f = open("小娃娃", mode="r+", encoding="utf-8")
content = f.read()
f.write("麻花藤的最爱")
print(content)
f.flush()
f.close()
结果:
正常的读取之后, 写在结尾
错误操作:
f = open("小娃娃", mode="r+", encoding="utf-8")
f.write("哈哈")
content = f.read()
print(content)
f.flush()
f.close()
结果: 将开头的内容改写成了"哈哈", 然后读取的内容是后面的内容.
所以记住: r+模式下. 必须是先读取. 然后再写入
还有一些其他的带b的操作. 就不多赘述了. 就是把字符换成字节. 仅此而已
1.6. 修改文件以及另一种打开文件的方式(重点)
文件修改: 只能将文件中的内容读取到内存中, 将信息修改完毕, 然后将源文件删除, 将新文件的名字改成老文件的名字.
# 文件修改
import os
with open("小娃娃", mode="r", encoding="utf-8") as f1,\
open("小娃娃_new", mode="w", encoding="UTF-8") as f2:
content = f1.read()
new_content = content.replace("冰糖葫芦", "大白梨")
f2.write(new_content)
os.remove("小娃娃") # 删除源文件
os.rename("小娃娃_new", "小娃娃") # 重命名新文件
弊端: 一次将所有内容进行读取. 内存溢出. 解决方案: 一行一行的读取和操作
import os
with open("小娃娃", mode="r", encoding="utf-8") as f1,\
open("小娃娃_new", mode="w", encoding="UTF-8") as f2:
for line in f1:
new_line = line.replace("大白梨", "冰糖葫芦")
f2.write(new_line)
os.remove("小娃娃") # 删除源文件
os.rename("小娃娃_new", "小娃娃") # 重命名新文件
"""
(Ctrl键,,单击,解释关键词)
1.找到这个文件。双击打开它
open(文件路径,mode="", encoding="")
文件路径:
1.绝对路径
d:/test/xxxx.txt
2.相对路径
相对于当前你的程序所在的文件夹
../ 上一层文件夹
mode:
r : read 读取
w : write 写
a : append 附加
b : 读写的是非文本文件
with : 上下文,不需要手动去关闭一个文件 -->bytes
"""
open("国产自拍.txt")
open("../葫芦娃.txt")
open("../01_初识python/代码/倚天屠龙记.txt")
f = open("国产自拍.txt", mode="r", encoding ="utf-8")
content = f.read() # 全部读取
print(content)
line = f.readline().strip() #去掉字符事左石两端的空白。空格,换行,制表符
print(line) # 读一行 下移一行 # print 内部存在一个换行
line = f.readline().strip() #去掉字符事左石两端的空白。空格,换行,制表符
print(line) # 读一行 下移一行
content = f.readlines() # ['葫芦娃\n',葫萨娃\n','一根藤上七朵花\n', '风吹雨打都不怕\n', '啦啦啦啦啦........']
print(content)
# 最重要的一种文本读取方式(必须掌握)
for line in f: # 从f中读取到每一行数据
print(line.strip())
# 写入文件
# w模式下,如果文件不存在。自动的创建一个文件
# w模式下,每一次open都会清空掉文件中的内容
f = open("嫩模.txt", mode="w", encoding="utf-8")
f.write("胡辣汤")
f.close() # 每次操作之后养成好习惯。要关闭链接
#准备一个列表.要求把列表中的每项内容。 写入到文件中
lst = ['张无忌', "汪峰", "章子怡", "赵敏"]
f = open("打架.txt", mode="w", encoding="utf-8")
f.write(lst[0])
f.write("\n")
f.write(lst[1])
f.write("\n")
f.write(lst[2])
f.write("\n")
f.write(lst[3])
f .write("\n")
f.close()
lst = ['张无忌', "汪峰", "章子怡", "赵敏"]
f = open("打架.txt", mode ="w", encoding="utf-8") # 大多数情况下要把open写循环外面
for item in lst:
f.write(item)
f.write("\n")
f.close()
# a模式
f = open("打架.txt", mode="a", encoding="utf-8")
f.write("你好厉害")
f.close()
# with
with open("国产自拍.txt", mode="r", encoding="utf-8") as f: #f=open()
for line in f:
print(line.strip())
f.read() # I/O operation on closed file.
# 想要读取图片
# 在读写非文本文件的时候要加上b
with open("胡一菲.jpeg", mode="rb") as f:
for line in f:
print(line)
# 文件的复制:
# 从源文件中读取内容。写入到新路径去
with open("胡一菲.jpeg", mode="rb") as f1, \
open("../01初识python/胡二飞.jpeg", mode="wb") as f2:
for line in f1:
f2.write(line)
# 文件修改
import os # 和操作系统相关的模块引入
import time # 和时间有关的模块引入
#把文件中的周 -> 张
with open("人名单.txt", mode="r", encoding="utf-8") as f1, \
open("人名单副本.txt", mode="w", encoding="utf-8") as f2:
for line in f1:
line = line.strip() #去掉换行
if line.startswith("周"):
line = line.replace("周", "张") #修改
f2. write(line)
f2.write("\n")
time.sleep(3) # 让程序休眠3秒钟
#删除源文件
os.remove("人名单,txt")
time.sleep(3)
#把副本文件重命名成源文件
os.rename("人名单副本.txt", "人名单.txt")
# 写模式(w, wb)
# 写的时候注意. 如果没有文件. 则会创建文件, 如果文件存在. 则将原件中原来的内容删除, 再写入新内容
f = open("小娃娃", mode="w", encoding="utf-8")
f.write("金毛狮王")
f.flush() # 刷新. 养成好习惯
f.close()
# wb模式下. 可以不指定打开文件的编码. 但是在写文件的时候必须将字符串转化成utf-8的bytes数据
f = open("小娃娃", mode="wb")
f.write("金毛狮王".encode("utf-8"))
f.flush()
f.close()
追加(a, ab)
只要是a或者ab, a+ 都是在文件的末尾写入. 不论光标在任何位置.
在追加模式下. 我们写入的内容会追加在文件的结尾.
f = open("小娃娃", mode="a", encoding="utf-8")
f.write("麻花藤的最爱")
f.flush()
f.close()
# ab模式自己试一试就好了
# 读写模式(r+, r+b)
# 对于读写模式. 必须是先读. 因为默认光标是在开头的. 准备读取的. 当读完了之后再进行写入. 我们以后使用频率最高的模式就是r+
# 正确操作是:
f = open("小娃娃", mode="r+", encoding="utf-8")
content = f.read()
f.write("麻花藤的最爱")
print(content)
f.flush()
f.close()
# 结果:
# 正常的读取之后, 写在结尾
# 错误操作:
f = open("小娃娃", mode="r+", encoding="utf-8")
f.write("哈哈")
content = f.read()
print(content)
f.flush()
f.close()
# 结果: 将开头的内容改写成了"哈哈", 然后读取的内容是后面的内容.
# 所以记住: r+模式下. 必须是先读取. 然后再写入
# 还有一些其他的带b的操作. 就不多赘述了. 就是把字符换成字节. 仅此而已
修改文件以及另一种打开文件的方式(重点)
# 文件修改: 只能将文件中的内容读取到内存中, 将信息修改完毕, 然后将源文件删除, 将新文件的名字改成老文件的名字.
# 文件修改
import os
with open("小娃娃", mode="r", encoding="utf-8") as f1,\
open("小娃娃_new", mode="w", encoding="UTF-8") as f2:
content = f1.read()
new_content = content.replace("冰糖葫芦", "大白梨")
f2.write(new_content)
os.remove("小娃娃") # 删除源文件
os.rename("小娃娃_new", "小娃娃") # 重命名新文件
# 弊端: 一次将所有内容进行读取. 内存溢出. 解决方案: 一行一行的读取和操作
import os
with open("小娃娃", mode="r", encoding="utf-8") as f1,\
open("小娃娃_new", mode="w", encoding="UTF-8") as f2:
for line in f1:
new_line = line.replace("大白梨", "冰糖葫芦")
f2.write(new_line)
os.remove("小娃娃") # 删除源文件
os.rename("小娃娃_new", "小娃娃") # 重命名新文件
文件路径
必须要掌握的py基础
控制流
if条件判断
你在生活中是不是经常遇到各种选择,比如玩色子,猜大小,选衣服等等需要选择的状况. Python程序中也会遇到这种情况,这就用到了if语句。
第一种语法, 单分支:
# 第一种语法, 单分支
if 条件: # 引号是将条件与结果分开。
结果 # 四个空格,或者一个tab键,这个是告诉程序满足这个条件的
money = int(input("兜里的钱:"))
if money > 100:
print("大腰子. 没毛病")
print("回家睡觉")
# 注意: 此时, 不论条件成功与否<回家睡觉>一定会被打印.
# 第二种语法, 双分支
if 条件:
# 事情1
else:
# 事情2
money = int(input("兜里的钱:"))
if money > 100:
print("大腰子. 没毛病")
else:
print("望京小腰, 也可以")
print("回家睡觉")
# 第三种语法, 多分支
if 条件1:
结果1
elif 条件2:
结果2
elif 条件3:
结果3
…
else:
结果n
money = int(input("兜里的钱:"))
if money > 5000:
print("天上有个美丽的人间洗个脚")
elif money > 1000:
print("洗脚城洗的也挺干净")
elif money > 200:
print("小小足疗馆也不错哦")
else:
print("自己搓")
print("回家睡觉")
# 第四种语法(嵌套):
if 条件1:
if 条件2:
结果1
else:
结果2
else:
结果3
money = int(input("兜里的钱:"))
if money > 500:
age = int(input("年龄: "))
if age > 18:
print("洗个脚不过分")
else:
print("年龄太小, 洗不出感觉")
else:
print("没钱, 回家自己搓!")
while循环
关于循环, 我们必须要知道一个事情.
while 条件:
循环体
# 模拟一下循环听歌
while True:
print('我们不一样')
print('我们都一样')
print('有啥不一样')
我们可以使用while循环来帮我们解决一些重复性的操作.
案例1: 输出1, 2, 3, 4….100
i = 1
while i <= 100:
print(i)
i = i + 1
案例2: 两种方案输出1, 3, 5, 7, …, 99
i = 1
while i <= 100:
print(i)
i = i + 2
i = 1
while i <= 100:
if i%2 == 1:
print(i)
i = i + 1
如果条件为真, 就执行循环体, 然后再次判断条件.....直到条件为假. 结束循环.
反复的执行一段代码
- 关于True和False
True, 是真的意思. 翻译成人话: 对的, OK, 没毛病. 确定
False, 是假的意思. 翻译成人话: 不对劲, 错误, No. 有瑕疵. 不对劲
这个应该都能看懂.
但是下面这个, 需要各位去记住
# 几乎所有能表示为空的东西. 都可以认为是False
print(bool(0))
print(bool(""))
print(bool([]))
print(bool({}))
print(bool(set()))
print(bool(tuple()))
print(bool(None))
# 上面这一坨全是False, 相反的. 都是真. 利用这个特性. 我们可以有以下的一些写法
# 伪代码, 理解逻辑.
结果 = 提取器.提取(页面)
if 结果:
有结果. 我要保存结果
else:
没结果. ......
结束循环有两种方案:
1, 改变条件.
2, break
本小节, 给各位演示改变循环条件. 下小节我们来聊聊break
flag = True
while flag:
age = int(input("请输入你的年龄:"))
if age > 18:
print("进来吧, 小鬼")
flag = False
else:
print("年龄不够18, 重新输入. ")
break和continue
1, break: 立刻跳出循环. 打断的意思
while True:
s = input("输入你要喷的内容(Q退出):")
if s == "Q":
print("老娘今天心情好. 不跟你一般见识")
break # 直接结束循环
print("打野. 我想对你说:" + s)
2, continue: 停止本次循环, 继续执行下一次循环.
while True:
s = input("输入你要喷的内容(Q退出):")
if s == "Q":
print("老娘今天心情好. 不跟你一般见识")
continue # 停止当前本次循环. 继续执行下一次循环
print("打野. 我想对你说:" + s)
break一般很好理解. 难受的是continue.
给你们写一段伪代码. 自己斟酌一下. continue给我们带来的好处是什么
while True:
data = 从数据库读取的数据. 每次循环读取一条. 一共有100W条
if data == 垃圾数据: 通过条件判断. 把脏数据获取到了.
# 对于垃圾数据而言. 我们肯定是不希望处理的. 所以.此时怼上一个continue在合适不过
continue
…
疯狂的处理数据的代码(500多行)
sys.exit()提前结束程序
import sys
while True:
print('Type exit to exit.')
response = input()
if response == 'exit':
sys.exit()
print('You typed' + response + '.')
字符串 (万恶之源, 必须要会的, 而且要熟..)
原始字符串
字符串在爬虫
里. 必须要知道的几个操作:
索引和切片
索引, 就是第几个字符. 它从0开始.
切片, 从字符串中提取n个字符.
s = "我爱黎明,黎明爱我"
print(s[1])
print(s[0])
print(s[2:4]) 从第2个, 到第4个(取不到4)
strip()
我们从网页上提取的数据. 很多都是带有一些杂质的(换行, 空格),怎么去掉?
strip()可以去掉字符串左右两端
的空白(空格, 换行\n, 回车\r, 制表符\t)
s = " \t\t\t我的天哪\r\r \n\n " # 够乱的字符串
s1 = s.strip()
print(s1) # 好了 `我的天哪`
split()
split, 做切割的.
s = "10,男人本色,100000万" # 你在网页上提取到这样的一段数据. 现在我需要电影名称
tmps = s.split(",")
name = tmps[1]
print(name) # 男人本色
id, name, money = s.split(",") # 切割后. 把三个结果直接怼给三个变量
print(id)
print(name)
print(money)
replace()
replace, 字符串替换
s = "我 \t\t\n\n爱 黎 明 " # 这是你从网页上拿到的东西
s1 = replace(" ", "").replace("\t", "").replace("\n", "") # 干掉空格, \t, \n
print(s1) # 我爱黎明
f-string
格式化字符串的一种方案
s = "周杰伦"
s1 = f"我喜欢{s}" # 它会把一个变量塞入一个字符串
print(s1) # 我喜欢周杰伦
k = 10085
s2 = f"我的电话号是{k+1}" # 它会把计算结果赛入一个字符串
print(s2) # 我的电话号是10086
# 综上, f-string的大括号里, 其实是一段表达式.能计算出结果即可
upper() lower() isupper() islower()
isX 字符串方法
受42,拒绝secr3t!,接受secr3t。
startwith()和endswith()
join() 和 split()
join, 将列表拼接为一个完整的字符串
lst = ["我妈", "不喜欢", "黎明"] # 有时,由于网页结构的不规则, 导致获取的数据是这样的.
s1 = "".join(lst) # 用空字符串把lst中的每一项拼接起来
print(s1) # 我妈不喜欢黎明
lst2 = ["\n\r","\n\r","周杰伦\n\r", "\n不认识我\r"]
s2 = "".join(lst2).replace("\n", "").replace("\r", "")
print(s2) # 周杰伦不认识我
用rjust()、ljust()和center() 方法对齐文本
pyperclip 模块拷贝粘贴字符串
列表
列表, 我们未来遇见的仅次于字符串的一种数据类型. 它主要是能承载大量的数据. 理论上. 你的内存不炸. 它就能一直存
- 索引, 切片
列表的索引和切片逻辑与字符串完全一致
lst = ["赵本山", "王大陆", "大嘴猴", "马后炮"]
item1 = lst[2] # 大嘴猴
item2 = lst[1] # 王大陆
lst2 = lst[2:]
print(lst2) # ["大嘴猴", "马后炮"]
# 注意, 如果列表中没有数据. 取0会报错
lst = []
print(lst[0]) # 报错, Index out of bounds
# 注意, 如果给出的索引下标超过了列表的最大索引. 依然会报错
lst = ["123", "456"]
print(lst[9999]) # 报错, Index out of bounds
- 增加
给列表添加数据
lst = [11,22]
lst.append(33)
lst.append(44)
print(lst) # [11,22,33,44]
- 删除
删除数据(不常用, 好不容易爬到的数据. 为什么要删)
lst.remove("周润发") # 把周润发删掉
- 修改
lst = ["赵本山", "王大陆", "大嘴猴", "马后炮"]
lst[1] = "周杰伦"
print(lst) # ["赵本山", "周杰伦", "大嘴猴", "马后炮"]
- range
用for循环数数的一个东西
for i in range(10):
print(i) # 从0数到9
for i in range(5, 10):
print(i) # 从5 数到 9
- 查询(必会!!!!)
lst = ["赵本山", "周杰伦", "大嘴猴", "马后炮"]
print(lst[0])
print(lst[1])
print(lst[2])
print(lst[3])
# 循环列表的索引
for i in range(len(lst)):
print(lst[i])
# 循环列表的内容
for item in lst:
print(item)
#定义:能装东西的东西
#在python中用[]来表示一个列表。列表中的元素通过,隔开
# a =["张三丰”,"张无忌","张绍刚", [1,2,3,True, ]]
#特性:
# 1.也像字符串一样也有索引和切片
# 2.索引如果超过范围会报错
# 3.可以用for循环进行遍历
# 4.用len可以拿到列表的长度
lst = ["金毛狮王", "张绍刚", "张无忌", "郭麒麟"]
#print(lst[0]) # 金毛狮王
# print(lst [1:3]) # ['张绍刚','张无忌 ']
# print(lst[::-1]) # ['郭麒麟','张无忌','张绍刚','金毛狮王']
print(lst[3652]) # list index out of range
for item in lst:
print (item)
print(len(lst))
##增加
lst = [] # 向列表中添加内容
# append() 追加
lst.append("张绍刚")
lst.append("赵本山")
lst.append("张无忌")
# insert() 插入
lst.insert(0, "赵敏")
# extend( ) 可以合并两个列表,批量的添加
lst.extend(['武则天', "嬴政", "马超"])
print(lst) #["赵敏", "张绍刚", "赵本山", "张无忌", '武则天', "嬴政", "马超"]
##删除
ret = lst.pop(3) #给出被删除的索引。返回被删除的元素
print( lst)
print(ret )
lst. remove("马超") # 删除某个元素(*)
print(lst)
##修改
lst[4] = "恺" # 直接用索引就可以进行修改操作
print( lst)
##查找
lst.indrx('恺') # 4
#小练习:
# 把所有的姓张的人修改成姓王
lst = ['赵敏', '张绍刚', '张无忌', '武则天', '赢政', '马超']
# lst[1] = "王绍刚"
# for item in lst: # 此时,我们看不到元素的索引位置
for i in range(len(lst)): # len(lst)列表的长度-> 可以直接拿到列表索引的for循环
item = lst[i] # item依然是列表中的每一项
if item. startswith("张"):
#张绍刚
new_ name =“王"+item[1: ]
print(new_name )
#把新名字手向列表(需要索引了?)
lst[i] = new_name # 修改
print(lst)
# 排序
lst = [1, 2, 3, "麻花藤", "武大郎"] #列表会按照你存放的顺序来保存
print( lst)
lst = [222, 444, 123, 43, 123 , 43243,111]
lst.sort()
# 对列表进行升序排序
# lst.sort(reverse=True) # reverse 翻转
# print(lst)
## 列表的嵌套
lst = ["abc","def",["呵呵哒","妈妈呀”,“苦苦脊瓦",["可乐","Ecrapy",123]], 'aed',"qpr"]
print(lst[2][3][1]) # Ecrapy
Lst[2][3][1] = lst[2][3][1].upper() # 大写
print(lst) # ["abc","def",["呵呵哒","妈妈呀”,“苦苦脊瓦",["可乐","ECRAPY",123]], 'aed',"qpr"]
# 列表的循环删除(*)
lst = ['赵敏','张绍刚','张无忌','武则天','蠃政','马超']
temp = [] # 准备一个临时列表,负责存储要删除的内容
for item in lst:
if item.startswith("张"):
temp.append(item) # 把要删除的内容记录下来
lst.remove(item) # 有bug
for item in temp:
lst.remove(item) # 去原列表中进行删除操作
print(lst)
# 安全稳妥的循环删除方式:
# 将要删除的内容保存在一个新列表中。循环新列表。删除老列表
# tuple 元组,特点: 不可变的列表
t = ("张无忌","赵敏","呵呵哒")
print(t)
print(t[1:3])
t[0] = "樵夫" # 'tuple' object does not support item ass ignment
print(t)
# 你固定了某些数据。不允许外界修改
# 元组如果只有1个元素(*),需要在元素的末尾添加一个逗号
t = ("哈哈",) # ()默认是优先级
print( (1+3) * 6) # 24
print(t)
print(type(t))
# 关于元组的不可变(坑),内存地址不能变。
t = (1,2,3, ["呵呵哒","么么哒"]) # (张三,李四,王二麻子)
t[3].append("哒哒哒")
print(t) # (1,2,3, ["呵呵哒","么么哒","哒哒哒"])
list() 和 tuple()函数来转换类型
引用
传递引用
字典
字典可以成对儿的保存数据.
- 增加
dic = {}
dic['name'] = '樵夫'
dic['age'] = 18
print(dic) # {"name": "樵夫", "age": 18}
- 修改
dic = {"name": "樵夫", "age": 18}
dic['age'] = 19
print(dic) # {"name": "樵夫", "age": 19}
- 删除(不常用)
dic = {"name": "樵夫", "age": 18}
dic.pop("age")
print(dic) # {'name': '樵夫'}
- 查询(重点)
dic = {"name": "樵夫", "age": 18}
a = dic['name'] # 查询'name'的值
print(a) # 樵夫
b = dic['age'] # 拿到dic中age对应的值
print(b) # 18
c = dic['哈拉少'] # 没有哈拉少. 报错
d = dic.get("哈拉少") # 没有哈拉少, 不报错. 返回None. 它好. 它不报错
循环
dic = {"name": "樵夫", "age": 18}
for k in dic: # 循环出所有的key
print(k)
print(dic[k]) # 获取到所有的value并打印
嵌套
dic = {
"name": "王峰",
"age": 18,
"wife": {
"name": "章子怡",
"age": 19,
},
"children": [
{'name':"胡一菲", "age": 19},
{'name':"胡二菲", "age": 18},
{'name':"胡三菲", "age": 17},
]
}
# 王峰的第二个孩子的名字
print(dic['children'][1]['name'])
# 王峰所有孩子的名称和年龄
for item in dic['children']:
print(item['name'])
print(item['age'])
字符集和bytes
字符集, 记住两个字符集就够了. 一个是utf-8, 一个是gbk. 都是支持中文的。但是utf-8的编码数量远大于gbk. 我们平时使用的最多的是utf-8。
# 把字符串转化成字节
bs = "我的天哪abcdef".encode("utf-8")
print(bs) # b'\xe6\x88\x91\xe7\x9a\x84\xe5\xa4\xa9\xe5\x93\xaaabcdef'
# 一个中文在utf-8里是3个字节. 一个英文是一个字节. 所以英文字母是正常显示的
# 把字节还原回字符串
bs = b'\xe6\x88\x91\xe7\x9a\x84\xe5\xa4\xa9\xe5\x93\xaaabcdef'
s = bs.decode("utf-8")
print(s)
记住, bytes不是给人看的. 是给机器看的. 我们遇到的所有文字, 图片, 音频, 视频. 所有所有的东西到了计算机里都是字节.
'''
1.字符集和编码
0 1 <=> 1010101010 => 二进制转化成十进制 <=> 88
电脑如何进行存储文字信息
1000000 <=> a
ascii => 编排了128个文字符号.只需要7个0和1就可以表示了. 01111111 => 1 byte => 8 bit
ANSI => 一套标准,每个字符16bit, 2byte
00000000 01111111
到了中国,gb2312编码, gbk编码(windows 默认的就是这个)
到了台湾, big5编码
到了日本,JIS编码
Unicode: 万国码. 中文
早期Unicode没有意识到这个问题。UCS-2 2个字节.
进行了扩充,UCS-4 4个字节
00000000 00000000 00000000 01111111
utf:是可变长度的unicode.可以进行数据的传输和存储->行书,草书,隶书
utf-8: 最短的字节长度8
英文: 8bit, 1byte
欧洲文字: 16bit, 2byte
中文: 24bit, 3byte
utf-16: 最短的字节长度16
总结:
1. ascii: 8bit, 1byte
2. gbk; 16bit, 2byte windows默认
3. unicode: 32bit, 4byte(没法用,只是一个标准)
4. utf-8: mac默认
英文: 8bit, 1byte
欧洲: 16bit, 2byte
中文: 24bit, 3byte
gbk和utf-8 不能直接就进行转化.
我军密码本 -> 文字 -> 敌军密码本
2. bytes
程序员平时遇见的所有的数据最终单位都是字节byte
'''
S="周杰伦"
bs1 = s.encode("gbk") # b'xxxx' bytes类型
bs2 = s.encode ("utf-8")
print(bs1) # b'\xd6\xdc\xbd\xdc\xc2\xd7'
print (bs2) # b'\xe5\x91\xa8\xe6\x9d\xb0\xe4\xbc\xa6'
# 怎么把一个gbk的字节转化成utf-8的字节
bs = b'\xd6\xdc\xbd\xdc\xc2\xd7' #先变成文字符号(字符串)
s = bs.decode("gbk") # 解码
bs2 = s.encode("utf-8") # 重新编码
print(bs2) # b'\xe5\x91\xa8\xe6\x9d\xb0\xe4\xbc\xa6'
#1. strencode("编码") 进行编码
#2. bytes.decode("编码") 进行解码
s1 = "你好abc呵呵哒"
s2 = "abcdefg"
print(s1.encode("utf-8")) # b'\xe4\xbd\xa0\xe5\xa5\xbdabc\xe5\x91\xb5\xe5\x91\xb5\xe5\x93\x92'
print(s2.encode("utf-8")) # b'abcdefg'
关于模块
模块是啥? 模块就是已经有人帮我们写好了的一些代码, 这些代码被保存在一个py文件或者一个文件夹里. 我们可以拿来直接用。
使用模块有什么好处?
1. 最⼤的好处是⼤⼤提⾼了代码的可维护性。其次,编写代码不必从零开始。当⼀个模块编写完毕,就可以被其他地⽅引⽤。我们在编写程序的时候,也经常引⽤其他模块,包括Python内置的模块和来⾃第三⽅的模块。
2. 使⽤模块还可以避免函数名和变量名冲突。每个模块有独⽴的命名空间,因此相同名字的函数和变量完全可以分别存在不同的模块中,所以,我们⾃⼰在编写模块时,不必考虑名字会与其他模块冲突。
在python中有三种模块:
第一种, python内置模块:不用安装. 直接导入就能用
第二种, 第三方模块:需要安装. 安装后. 导入就可以用了
第三种, 自定义模块(新手先别自己定义模块):直接导入就能用
导入模块的语法:
import 模块
from 模块 import 功能
from 模块.子模块 import 功能
import module_a #导⼊
from module import xx # 导⼊某个模块下的某个⽅法 or ⼦模块
from module.xx.xx import xx as rename #导⼊后⼀个⽅法后重命令
from module.xx.xx import * #导⼊⼀个模块下的所有⽅法,不建议使⽤
module_a.xxx #调⽤
举例子,
import os
import sys
from urllib.parse import urljoin
from bs4 import BeautifulSoup
注意:模块⼀旦被调⽤,即相当于执⾏了另外⼀个py⽂件⾥的代码
# cmd 中
pip install 库(xlrd)
# python 中
import 库(xlrd)
1 自定义模块
这个最简单, 创建⼀个.py⽂件,就可以称之为模块,就可以在另外⼀个程序⾥导⼊:
2 模块的查找路径
有没有发现,⾃⼰写的模块只能在当前路径下的程序⾥才能导⼊,换⼀个⽬录再导⼊⾃⼰的模块就报错
说找不到了, 这是为什么?
这与导⼊模块的查找路径有关。
import sys
print(sys.path)
# 输出(注意不同的电脑可能输出的不太⼀样)
['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sitepackages']
你导⼊⼀个模块时,Python解释器会按照上⾯列表顺序去依次到每个⽬录下去匹配你要导⼊的模块名,只要在⼀个⽬录下匹配到了该模块名,就⽴刻导⼊,不再继续往后找。
注意列表第⼀个元素为空,即代表当前⽬录,所以你⾃⼰定义的模块在当前⽬录会被优先导⼊。
我们⾃⼰创建的模块若想在任何地⽅都能调⽤,那就得确保你的模块⽂件⾄少在模块路径的查找列表中。
我们⼀般把⾃⼰写的模块放在⼀个带有“site-packages”字样的⽬录⾥,我们从⽹上下载安装的各种第三⽅的模块⼀般都放在这个⽬录。
3 第3方开源模块安装
https://pypi.python.org/pypi 是python的开源模块库,截⽌2020年5.26⽇ ,已经收录了236,269个来⾃全世界python开发者贡献的模块,⼏乎涵盖了你想⽤python做的任何事情。 事实上每个python开发者,只要注册⼀个账号就可以往这个平台上传你⾃⼰的模块,这样全世界的开发者都可以容易的下载并使⽤你的模块。
这个是我写的:
这是我弟弟写的:
那如何从这个平台上下载代码呢?
1. 直接在上⾯这个⻚⾯上点download,下载后,解压并进⼊⽬录,执⾏以下命令完成安装
编译源码
python setup.py build 安装源码
python setup.py install
2. 直接通过pip安装
pip3 install paramiko #paramiko 是模块名
pip命令会⾃动下载模块包并完成安装。
软件⼀般会被⾃动安装你python安装⽬录的这个⼦⽬录⾥
/your_python_install_path/3.6/lib/python3.6/site-packages
pip命令默认会连接在国外的python官⽅服务器下载,速度⽐较慢,你还可以使⽤国内的⾖瓣源,数据会定期同步国外官⽹,速度快好多
pip install -i http://pypi.douban.com/simple/ alex_sayhi --trusted-host
pypi.douban.com #alex_sayhi是模块名
-i 后⾯跟的是⾖瓣源地址:
—trusted-host 得加上,是通过⽹站https安全验证⽤的。
使用:
下载后,直接导⼊使⽤就可以,跟⾃带的模块调⽤⽅法⽆差。
4 python内置模块
搞爬虫.必须要了解的一些python内置模块:
1 time模块
import time
time.time() # 这个是获取到时间戳
time.sleep(999) # 让程序暂停999秒
在平常的代码中,我们常常需要与时间打交道。在Python中,与时间处理有关的模块就包括:time,
datetime,calendar(很少⽤,不讲),下⾯分别来介绍。
我们写程序时对时间的处理可以归为以下3种:
时间的显示,在屏幕显示、记录⽇志等 "2022-03-04"
时间的转换,⽐如把字符串格式的⽇期转成Python中的⽇期类型
时间的运算,计算两个⽇期间的差值等
在Python中,通常有这⼏种⽅式来表示时间:
1. 时间戳(timestamp), 表示的是从1970年1⽉1⽇00:00:00开始按秒计算的偏移量。例⼦:
1554864776.161901
2. 格式化的时间字符串,⽐如“2020-10-03 17:54”
3. 元组(struct_time)共九个元素。由于Python的time模块实现主要调⽤C库,所以各个平台可能
有所不同,mac上:time.struct_time(tm_year=2020, tm_mon=4, tm_mday=10, tm_hour=2,
tm_min=53, tm_sec=15, tm_wday=2, tm_yday=100, tm_isdst=0)
索引(Index) 属性(Attribute) 值(Values)
0 tm_year(年) ⽐如2011
1 tm_mon(⽉) 1 - 12
2 tm_mday(⽇) 1 - 31
3 tm_hour(时) 0 - 23
4 tm_min(分) 0 - 59
5 tm_sec(秒) 0 - 61
6 tm_wday(weekday) 0 - 6(0表示周⼀)
7 tm_yday(⼀年中的第⼏天) 1 - 366
8 tm_isdst(是否是夏令时) 默认为-1
UTC时间
UTC(Coordinated Universal Time,世界协调时)亦即格林威治天⽂时间,世界标准时间。在中国为UTC+8,⼜称东8区。DST(Daylight Saving Time)即夏令时。
time模块的常用方法
time.localtime([secs]) :将⼀个时间戳转换为当前时区的struct_time。若secs参数未提供,则以当前时间为准。
time.gmtime([secs]) :和localtime()⽅法类似,gmtime()⽅法是将⼀个时间戳转换为UTC时区(0时区)的struct_time。
time.time() :返回当前时间的时间戳。
time.mktime(t) :将⼀个struct_time转化为时间戳。
time.sleep(secs) :线程推迟指定的时间运⾏,单位为秒。
time.strftime(format[, t]) :把⼀个代表时间的元组或者struct_time(如由
time.localtime()和time.gmtime()返回)转化为格式化的时间字符串。如果t未指定,将传⼊time.localtime()。
举例: time.strftime(“%Y-%m-%d %X”, time.localtime()) #输出’2017-10-01
12:14:23’
time.strptime(string[, format]) :把⼀个格式化时间字符串转化为struct_time。实际上它和strftime()是逆操作。
举例: time.strptime(‘2017-10-3 17:54’,”%Y-%m-%d %H:%M”) #输出
time.struct_time(tm_year=2017, tm_mon=10, tm_mday=3, tm_hour=17, tm_min=54, tm_sec=0, tm_wday=1, tm_yday=276, tm_isdst=-1)
字符串转时间格式对应表
最后为了容易记住转换关系,看下图:
2 datetime模块
相⽐于time模块,datetime模块的接⼝则更直观、更容易调⽤
datetime模块定义了下⾯这⼏个类:
datetime.date:表示⽇期的类。常⽤的属性有year,month,day;
datetime.time:表示时间的类。常⽤的属性有hour, minute, second, microsecond;
datetime.datetime:表示⽇期时间。
datetime.timedelta:表示时间间隔,即两个时间点之间的长度。
datetime.tzinfo:与时区有关的相关信息。(这⾥不详细充分讨论该类,感兴趣的童鞋可以参考python⼿册)
我们需要记住的方法仅以下⼏个:
1. d=datetime.datetime.now() 返回当前的datetime⽇期类型, d.timestamp(),d.today(), d.year,d.timetuple()等⽅法可以调⽤
2. datetime.date.fromtimestamp(322222) 把⼀个时间戳转为datetime⽇期类型
3. 时间运算
>>> datetime.datetime.now()
datetime.datetime(2017, 10, 1, 12, 53, 11, 821218)
>>> datetime.datetime.now() + datetime.timedelta(4) #当前时间 +4天
datetime.datetime(2017, 10, 5, 12, 53, 35, 276589)
>>> datetime.datetime.now() + datetime.timedelta(hours=4) #当前时间+4⼩时
datetime.datetime(2017, 10, 1, 16, 53, 42, 876275)
4. 时间替换
>>> d.replace(year=2999,month=11,day=30)
datetime.date(2999, 11, 30)
3 系统调用os模块
os 模块提供了很多允许你的程序与操作系统直接交互的功能。
import os
# 判断文件是否存在
os.path.exists() # 判断文件或者文件夹是否存在
os.path.join() # 路径拼接
os.makedirs() # 创建文件夹
得到当前⼯作⽬录,即当前Python脚本⼯作的⽬录路径: os.getcwd()
返回指定⽬录下的所有⽂件和⽬录名:os.listdir()
函数⽤来删除⼀个⽂件:os.remove()
删除多个⽬录:os.removedirs(r“c:\python”)
检验给出的路径是否是⼀个⽂件:os.path.isfile()
检验给出的路径是否是⼀个⽬录:os.path.isdir()
判断是否是绝对路径:os.path.isabs()
检验给出的路径是否真地存:os.path.exists()
返回⼀个路径的⽬录名和⽂件名:os.path.split() e.g
os.path.split('/home/swaroop/byte/code/poem.txt') 结果:
('/home/swaroop/byte/code', 'poem.txt')
分离扩展名:os.path.splitext() e.g os.path.splitext('/usr/local/test.py')
结果:('/usr/local/test', '.py')
获取路径名:os.path.dirname()
获得绝对路径: os.path.abspath()
获取⽂件名:os.path.basename()
运⾏shell命令: os.system()
读取操作系统环境变量HOME的值:os.getenv("HOME")
返回操作系统所有的环境变量: os.environ
设置系统环境变量,仅程序运⾏时有效:os.environ.setdefault('HOME','/home/alex')
给出当前平台使⽤的⾏终⽌符:os.linesep Windows使⽤'\r\n',Linux and MAC使⽤'\n'
指示你正在使⽤的平台:os.name 对于Windows,它是'nt',⽽对于Linux/Unix⽤户,它
是'posix'
重命名:os.rename(old, new)
创建多级⽬录:os.makedirs(r“c:\python\test”)
创建单个⽬录:os.mkdir(“test”)
获取⽂件属性:os.stat(file)
修改⽂件权限与时间戳:os.chmod(file)
获取⽂件⼤⼩:os.path.getsize(filename)
结合⽬录名与⽂件名:os.path.join(dir,filename)
改变⼯作⽬录到dirname: os.chdir(dirname)
获取当前终端的⼤⼩: os.get_terminal_size()
杀死进程: os.kill(10884,signal.SIGKILL)
4 json模块(重中之重)
现在的网站不同于从前了. 习惯性用json来传递数据. 所以, 我们必须要知道json是啥, 以及python如何处理json.
json是一种类似字典一样的东西. 对于python而言, json是字符串.
JSON(JavaScriptObject Notation, JS 对象简谱) 是⼀种轻量级的数据交换格式。它采⽤完全独⽴于编程语⾔的⽂本格式来存储和表示数据。简洁和清晰的层次结构使得 JSON 成为理想的数据交换语⾔。 易于⼈阅读和编写,同时也易于机器解析和⽣成,并有效地提升⽹络传输效率。
Json的作⽤是⽤于不同语⾔接⼝间的数据交换,⽐如你把python的list、dict直接扔给javascript, 它是解析不了的。2个语⾔互相谁也不认识。Json就像是计算机界的英语 ,可以帮各个语⾔之间实现数据类型的相互转换。
例如,
s = '{"name": "jay", "age": 18}'
你看. 这破玩意就是json
如何来转化它.
json字符串 => python字典
import json
s = '{"name": "jay", "age": 18}'
dic = json.loads(s)
print(type(dic))
python字典 => json字符串
import json
dic = {"name": "jay", "age": 18}
s = json.dumps(dic)
print(type(s))
JSON⽀持的数据类型
Python中的字符串、数字、列表、字典、集合、布尔 类型,都可以被序列化成JSON字符串,被其它任何编程语⾔解析。
什么是序列化?
序列化是指把内存⾥的数据类型转变成字符串,以使其能存储到硬盘或通过⽹络传输到远程,因为硬盘或⽹络传输时只能接受bytes。
为什么要序列化?
你打游戏过程中,打累了,停下来,关掉游戏、想过2天再玩,2天之后,游戏⼜从你上次停⽌的地⽅继续运⾏,你上次游戏的进度肯定保存在硬盘上了,是以何种形式呢?游戏过程中产⽣的很多临时数据是不规律的,可能在你关掉游戏时正好有10个列表,3个嵌套字典的数据集合在内存⾥,需要存下来?你如何存?把列表变成⽂件⾥的多⾏多列形式?那嵌套字典呢?
根本没法存。所以,若是有种办法可以直接把内存数据存到硬盘上,下次程序再启动,再从硬盘上读回来,还是原来的格式的话,那是极好的。
⽤于序列化的两个模块:
json,⽤于字符串 和 python数据类型间进⾏转换。
pickle,⽤于python特有的类型 和 python的数据类型间进⾏转换。
pickle
模块提供了四个功能:dumps、dump、loads、load
import pickle
data = {'k1':123,'k2':'Hello'}
# pickle.dumps 将数据通过特殊的形式转换位只有python语⾔认识的字符串
p_str = pickle.dumps(data) # 注意dumps会把数据变成bytes格式
print(p_str)
# pickle.dump 将数据通过特殊的形式转换位只有python语⾔认识的字符串,并写⼊⽂件
with open('result.pk',"wb") as fp:
pickle.dump(data,fp)
# pickle.load 从⽂件⾥加载
f = open("result.pk","rb")
d = pickle.load(f)
print(d)
json
Json模块也提供了四个功能:dumps、dump、loads、load,⽤法跟pickle⼀致
import json
# json.dumps 将数据通过特殊的形式转换位所有程序语⾔都认识的字符串
j_str = json.dumps(data) # 注意json dumps⽣成的是字符串,不是bytes
print(j_str)
#dump⼊⽂件
with open('result.json','w') as fp:
json.dump(data,fp)
#从⽂件⾥load
with open("result.json") as f:
d = json.load(f)
print(d)
json vs pickle:
JSON:
优点:跨语⾔(不同语⾔间的数据传递可⽤json交接)、体积⼩
缺点:只能⽀持int\str\list\tuple\dict
Pickle:
优点:专为python设计,⽀持python所有的数据类型
缺点:只能在python中使⽤,存储数据占空间⼤
5 random模块
程序中有很多地⽅需要⽤到随机字符,⽐如登录⽹站的随机验证码,通过random模块可以很容易⽣成随机字符串
import random
i = random.randint(1, 10) # 1~10的随机数
print(i) # 多跑两次.效果更加
>>> random.randrange(1,10) #返回1-10之间的⼀个随机数,不包括10
>>> random.randint(1,10) #返回1-10之间的⼀个随机数,包括10
>>> random.randrange(0, 100, 2) #随机选取0到100间的偶数
>>> random.random() #返回⼀个随机浮点数
>>> random.choice('abce3#$@1') #返回⼀个给定数据集合中的随机字符
'#'
>>> random.sample('abcdefghij',3) #从多个字符中选取特定数量的字符
['a', 'd', 'b']
#⽣成随机字符串
>>> import string
>>> ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
'4fvda1'
#洗牌
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> random.shuffle(a)
>>> a
[3, 0, 7, 2, 1, 6, 5, 8, 9, 4]
- 异常处理
这个是重点. 我们在写爬虫的时候. 非常容易遇到问题. 但这些问题本身并不是我们程序的问题.
比如, 你在抓取某网站的时候. 由于网络波动或者他服务器本身压力太大. 导致本次请求失败. 这种现象太常见了. 此时, 我们程序这边就会崩溃. 打印一堆红色的文字. 让你难受的一P. 怎么办?
我们要清楚一个事情. 我们平时在打开一个网址的时候. 如果长时间没有反应, 或者加载很慢的时候. 我们习惯性的会刷新网页. 对吧. 这个逻辑就像:程序如果本次请求失败了. 能不能重新来一次
. OK, 我们接下来聊的这个异常处理. 就是干这个事儿的.
try: # 尝试...
print("假如, 我是一段爬虫代码, 请求到对方服务器")
print("我得出事儿啊")
print(1/0) # 出事儿了
except Exception as e: # 出错了. 我给你兜着
print(e) # 怎么兜? 打印一下. 就过去了
print("不论上面是否出错. 我这里, 依然可以执行")
看懂了么? 程序执行的时候. 如果try
中的代码出现错误. 则自动跳到except
中. 并执行except
中的代码. 然后程序正常的, 继续执行
有了这玩意. 我们就可以写出一段很漂亮的代码逻辑:
改良版:
while 1:
try:
我要发送请求了. 我要干美国CIA的总部. 我要上天
print("我成功了!!")
break # 成功了.就跳出循环
except Exception as e:
print("失败了")
print("我不怕失败")
print("再来")
改良版:
import time
for i in range(10):
try:
我要发送请求了. 我要干美国CIA的总部. 我要上天
print("我成功了!!")
break # 成功了.就跳出循环
except Exception as e:
print("失败了")
print("我不怕失败")
print("再来")
time.sleep(i * 10)
random 模块提供的工具可以生成0~1之间的随机浮点数、两个数字之间的任意整数、
序列中的任意一项。
Python中的布尔类型为 bool ,它只有两个值True和False。
True 和False是预定义的内置变量名,其在表达式中的行为与整数1和0是一样的。实际上他们就是内置的int 类型的子类。
6 Excel处理模块
第3⽅开源模块,安装
pip install openpyxl
1 打开文件
⼀、创建
from openpyxl import Workbook
# 实例化
wb = Workbook()
# 获取当前active的sheet
ws = wb.active
print(sheet.title) # 打印sheet表名
sheet.title = "salary luffy" # 改sheet 名
⼆、打开已有⽂件
>>> from openpyxl import load_workbook
>>> wb2 = load_workbook('⽂件名称.xlsx')
2 写数据
# ⽅式⼀:数据可以直接分配到单元格中(可以输⼊公式)
sheet["C5"] = "Hello ⾦⻆⼤王"
sheet["C7"] = "Hello ⾦⻆⼤王2"
# ⽅式⼆:可以附加⾏,从第⼀列开始附加(从最下⽅空⽩处,最左开始)(可以输⼊多⾏)
sheet.append([1, 2, 3])
# ⽅式三:Python 类型会被⾃动转换
sheet['A3'] = datetime.datetime.now().strftime("%Y-%m-%d")
3 选择表
# sheet 名称可以作为 key 进⾏索引
ws3 = wb["New Title"]
ws4 = wb.get_sheet_by_name("New Title")
print(wb.get_sheet_names()) # 打印所有的sheet
sheet = wb.worksheets[0] # 获得第1个sheet
4 保存表
wb.save('⽂件名称.xlsx')
5 遍历表数据
# 按⾏遍历
for row in sheet: # 循环获取表数据
for cell in row: # 循环获取每个单元格数据
print(cell.value, end=",")
print()
# 按列遍历
# A1, A2, A3这样的顺序
for column in sheet.columns:
for cell in column:
print(cell.value,end=",")
print()
# 遍历指定⾏&列
# 从第2⾏开始⾄第5⾏,每⾏打印5列
for row in sheet.iter_rows(min_row=2,max_row=5,max_col=5):
for cell in row:
print(cell.value,end=",")
print()
# 遍历指定⼏列的数据
# 取得第2-第5列的数据
for col in sheet.iter_cols(min_col=2,max_col=5,):
for i in col:
print(i.value,end=",")
print()
6 删除⼯作表
# ⽅式⼀
wb.remove(sheet)
# ⽅式⼆
del wb[sheet]
7 设置单元格样式
# ⼀、需导⼊的类
from openpyxl.styles import Font, colors, Alignment
# ⼆、字体
# 下⾯的代码指定了等线24号,加粗斜体,字体颜⾊红⾊。直接使⽤cell的font属性,将Font对象赋值给它。
bold_itatic_24_font = Font(name='等线', size=24, italic=True, color=colors.RED,
bold=True) # 声明样式
sheet['A1'].font = bold_itatic_24_font # 给单元格设置样式
# 三、对⻬⽅式
# 也是直接使⽤cell的属性aligment,这⾥指定垂直居中和⽔平居中。除了center,还可以使⽤right、left等等参数。
# 设置B1中的数据垂直居中和⽔平居中
sheet['B1'].alignment = Alignment(horizontal='center', vertical='center')
# 四、设置⾏⾼&列宽
# 第2⾏⾏⾼
sheet.row_dimensions[2].height = 40
# C列列宽
sheet.column_dimensions['C'].width = 30
7 邮件发送smtplib
SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是⼀组⽤于由源地址到⽬的地址传送邮件的规则,由它来控制信件的中转⽅式。
想实现发送邮件需经过以下⼏步:
1. 登录 邮件服务器
2. 构造符合邮件协议规则要求的邮件内容 (email模块)
3. 发送
Python对SMTP⽀持有 smtplib 和 email 两个模块, email 负责构造邮件, smtplib 负责发送邮件,它对smtp协议进⾏了简单的封装。
1 发送⼀封最简单的信语法如下:
import smtplib
from email.mime.text import MIMEText # 邮件正⽂
from email.header import Header # 邮件头
# 登录邮件服务器
smtp_obj = smtplib.SMTP_SSL("smtp.exmail.qq.com", 465) # 发件⼈邮箱中的SMTP服务
器,端⼝是25
smtp_obj.login("nami@luffycity.com", "xxxx-sd#gf") # 括号中对应的是发件⼈邮箱账
号、邮箱密码
#smtp_obj.set_debuglevel(1) # 显示调试信息
# 设置邮件头信息
msg = MIMEText("Hello, ⼩哥哥,约么?800上⻔,新到学⽣妹...", "plain", "utf-8")
msg["From"] = Header("来⾃娜美的问候","utf-8") # 发送者
msg["To"] = Header("有缘⼈","utf-8") # 接收者
msg["Subject"] = Header("娜美的信","utf-8") # 主题
# 发送
smtp_obj.sendmail("nami@luffycity.com", ["alex@luffycity.com",
"317822232@qq.com"], msg.as_string())
2 发送HTML格式的邮件
只需要改⼀下 MIMEText() 第2个参数为 html 就可以
# 设置邮件头信息
mail_body = '''
<h5>hello,⼩哥哥</h5>
<p>
⼩哥哥,约么?800,新到学⽣妹.. <a
href="http://wx1.sinaimg.cn/mw1024/5ff6135fgy1gdnghz2vbsg205k09ob2d.gif">这是我
的照⽚</a></p>
</p>
'''
msg = MIMEText(mail_body, "html", "utf-8")
3 在HTML⽂本中插⼊图⽚
有兴趣的可以⾃⼰研究
# -*- coding:utf-8 -*-
# created by Alex Li - 路⻜学城
import smtplib
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
# 登录邮件服务器
smtp_obj = smtplib.SMTP_SSL("smtp.exmail.qq.com", 465) # 发件⼈邮箱中的SMTP服务
器,端⼝是25
smtp_obj.login("nami@luffycity.com", "333dsfsf#$#") # 括号中对应的是发件⼈邮箱账
号、邮箱密码
smtp_obj.set_debuglevel(1) # 显示调试信息
# 设置邮件头信息
mail_body = '''
<h5>hello,⼩哥哥</h5>
<p>
⼩哥哥,约么?800,新到学⽣妹..
<p><img src="cid:image1"></p>
</p>
'''
msg_root = MIMEMultipart('related') # 允许添加附件、图⽚等
msg_root["From"] = Header("来⾃娜美的问候","utf-8") # 发送者
msg_root["To"] = Header("有缘⼈","utf-8") # 接收者
msg_root["Subject"] = Header("娜美的信","utf-8") # 主题
# 允许添加图⽚
msgAlternative = MIMEMultipart('alternative')
msgAlternative.attach(MIMEText(mail_body, 'html', 'utf-8'))
msg_root.attach(msgAlternative) # 把邮件正⽂内容添加到msg_root⾥
# 加载图⽚,
fp = open('girl.jpg', 'rb')
msgImage = MIMEImage(fp.read())
fp.close()
# 定义图⽚ ID,在 HTML ⽂本中引⽤
msgImage.add_header('Content-ID', '<image1>')
msg_root.attach(msgImage) # 添加图⽚到msg_root对象⾥
# 发送
smtp_obj.sendmail("nami@luffycity.com", ["alex@luffycity.com",
"317828332@qq.com"], msg_root.as_string())
8 inspect 模块
inspect 模块也提供了许多有用的函数,来获取活跃对象的信息。比方说,你可以查看一个对象的成员,只需运行:
import inspect
print(inspect.getmembers(str))
# Output: [('__add__', <slot wrapper '__add__' of ... ...
还有好多个其他方法也能有助于自省。如果你愿意,你可以去探索它们。
3.9 包(package)
若你写的项⽬较复杂,有很多代码⽂件的话,为了⽅便管理,可以⽤包来管理。 ⼀个包其实就是⼀个⽂件⽬录,你可以把属于同⼀个业务线的代码⽂件都放在同⼀个包⾥。
如何创建⼀个包?
只需要在⽬录下创建⼀个空的 __init__.py ⽂件 , 这个⽬录就变成了包。这个⽂件叫包的初始化⽂件,⼀般为空,当然也可以写东⻄,当你调⽤这个包下及其任意⼦包的的任意模块时, 这个 __init__.py ⽂件都会先执⾏。
以下 有a、b 2个包,a2是a的⼦包,b2是b的⼦包
若在a_module.py模块⾥导⼊b2_mod.py的话,怎么办?
a_module.py的⽂件路径为
/Users/alex/Documents/work/PyProjects/py8days_camp/day6/课件/a/a2/a_module.py
想导⼊成功,直接写以下代码就可以:
from day6.课件.b.b2 import b2_mod
为何从day6开始?⽽不是从 py8days_camp 或 课件 开始呢?
因为你的sys.path列表⾥,已经添加了相关的路径:
['/Users/alex/Documents/work/PyProjects/py8days_camp/day6/课件/a/a2',
'/Users/alex/Documents/work/PyProjects/py8days_camp', # <---就是这个。。
'/Applications/PyCharm.app/Contents/helpers/pycharm_display',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sitepackages',
'/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend']
⼿动添加sys.path路径
你会说,我没有添加这个 '/Users/alex/Documents/work/PyProjects/py8days_camp' 呀,它是怎么进到 sys.path ⾥的?
答案是Pycharm⾃动帮你添加的,若你脱离pycharm再执⾏这个 a_module.py 就会报错了。
Alexs-MacBook-Pro:a2 alex$ python3 a_module.py
Traceback (most recent call last):
File "a_module.py", line 7, in <module>
from day6.课件.b.b2 import b2_mod
ModuleNotFoundError: No module named 'day6'
不⽤慌, ⾃⼰⼿动添加sys.path路径就可以:
import os
import sys
base_dir=os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.pa
th.dirname(os.path.abspath(__file__)))))) # 取到路
径/Users/alex/Documents/work/PyProjects/py8days_camp
print(base_dir)
sys.path.append(base_dir) # 添加到sys.path⾥
from day6.课件.b.b2 import b2_mod
今日作业
请想办法出下列json
中所有的英雄名称
和英雄title
. 并将英雄名称
和英雄title
写入names.txt
文件中.
{"hero":[{"heroId":"1","name":"\u9ed1\u6697\u4e4b\u5973","alias":"Annie","title":"\u5b89\u59ae","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"3","magic":"10","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/1.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/1.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2000","camp":"","campId":"","keywords":"\u5b89\u59ae,\u9ed1\u6697\u4e4b\u5973,\u706b\u5973,Annie,anni,heianzhinv,huonv,an,hazn,hn"},{"heroId":"2","name":"\u72c2\u6218\u58eb","alias":"Olaf","title":"\u5965\u62c9\u592b","roles":["fighter","tank"],"isWeekFree":"1","attack":"9","defense":"5","magic":"3","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/2.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/2.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"1500","camp":"","campId":"","keywords":"\u72c2\u6218\u58eb,\u5965\u62c9\u592b,kzs,alf,Olaf,kuangzhanshi,aolafu"},{"heroId":"3","name":"\u6b63\u4e49\u5de8\u50cf","alias":"Galio","title":"\u52a0\u91cc\u5965","roles":["tank","mage"],"isWeekFree":"0","attack":"1","defense":"10","magic":"6","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/3.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/3.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2000","camp":"","campId":"","keywords":"\u6b63\u4e49\u5de8\u50cf,\u52a0\u91cc\u5965,Galio,jla,zyjx,zhengyijuxiang,jialiao"},{"heroId":"4","name":"\u5361\u724c\u5927\u5e08","alias":"TwistedFate","title":"\u5d14\u65af\u7279","roles":["mage"],"isWeekFree":"0","attack":"6","defense":"2","magic":"6","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/4.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/4.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u5361\u724c\u5927\u5e08,\u5d14\u65af\u7279,\u5361\u724c,TwistedFate,kp,cst,kpds,kapaidashi,cuisite,kapai"},{"heroId":"5","name":"\u5fb7\u90a6\u603b\u7ba1","alias":"XinZhao","title":"\u8d75\u4fe1","roles":["fighter","assassin"],"isWeekFree":"0","attack":"8","defense":"6","magic":"3","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/5.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/5.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u5fb7\u90a6\u603b\u7ba1,\u5fb7\u90a6,\u8d75\u4fe1,XinZhao,db,dbzg,zx,debangzongguan,debang,zhaoxin"},{"heroId":"6","name":"\u65e0\u754f\u6218\u8f66","alias":"Urgot","title":"\u5384\u52a0\u7279","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/6.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/6.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"1000","camp":"","campId":"","keywords":"\u65e0\u754f\u6218\u8f66,\u5384\u52a0\u7279,ejt,wwzc,Urgot,wuweizhanche,ejiate"},{"heroId":"7","name":"\u8be1\u672f\u5996\u59ec","alias":"Leblanc","title":"\u4e50\u8299\u5170","roles":["assassin","mage"],"isWeekFree":"0","attack":"1","defense":"4","magic":"10","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/7.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/7.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2500","camp":"","campId":"","keywords":"\u8be1\u672f\u5996\u59ec,\u5996\u59ec,\u4e50\u8299\u5170,Leblanc,lfl,yj,gsyj,guishuyaoji,yaoji,lefulan"},{"heroId":"8","name":"\u7329\u7ea2\u6536\u5272\u8005","alias":"Vladimir","title":"\u5f17\u62c9\u57fa\u7c73\u5c14","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"6","magic":"8","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/8.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/8.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u7329\u7ea2\u6536\u5272\u8005,\u5438\u8840\u9b3c,\u5f17\u62c9\u57fa\u7c73\u5c14,fljme,xxg,xhsgz,Vladimir,xinghongshougezhe,xixiegui,fulajimier"},{"heroId":"9","name":"\u8fdc\u53e4\u6050\u60e7","alias":"FiddleSticks","title":"\u8d39\u5fb7\u63d0\u514b","roles":["mage","support"],"isWeekFree":"0","attack":"2","defense":"3","magic":"9","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/9.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/9.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u8fdc\u53e4\u6050\u60e7,\u8d39\u5fb7\u63d0\u514b,\u7a3b\u8349\u4eba,FiddleSticks,yuangukongju,feidetike,daocaoren,dcr,fdtk,ygkj"},{"heroId":"10","name":"\u6b63\u4e49\u5929\u4f7f","alias":"Kayle","title":"\u51ef\u5c14","roles":["fighter","support"],"isWeekFree":"0","attack":"6","defense":"6","magic":"7","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/10.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/10.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u6b63\u4e49\u5929\u4f7f,\u51ef\u5c14,\u5929\u4f7f,ts,zyts,ke,Kayle,zhengyitianshi,kaier,tianshi"},{"heroId":"11","name":"\u65e0\u6781\u5251\u5723","alias":"MasterYi","title":"\u6613","roles":["assassin","fighter"],"isWeekFree":"0","attack":"10","defense":"4","magic":"2","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/11.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/11.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u65e0\u6781\u5251\u5723,\u6613,\u5251\u5723,js,y,wjjs,MasterYi,wujijiansheng,yi,jiansheng"},{"heroId":"12","name":"\u725b\u5934\u914b\u957f","alias":"Alistar","title":"\u963f\u5229\u65af\u5854","roles":["tank","support"],"isWeekFree":"0","attack":"6","defense":"9","magic":"5","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/12.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/12.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"1000","camp":"","campId":"","keywords":"\u963f\u5229\u65af\u5854,\u725b\u5934,\u725b\u5934\u914b\u957f,\u914b\u957f,alisita,niutou,niutouqiuzhang,qiuzhang,Alistar,alst,nt,ntqz,qz"},{"heroId":"13","name":"\u7b26\u6587\u6cd5\u5e08","alias":"Ryze","title":"\u745e\u5179","roles":["mage","fighter"],"isWeekFree":"1","attack":"2","defense":"2","magic":"10","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/13.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/13.ogg","isARAMweekfree":"0","ispermanentweekfree":"1","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u7b26\u6587\u6cd5\u5e08,\u745e\u5179,Ryze,\u5149\u5934,rz,fwfs,gt,fuwenfashi,ruizi,guangtou"},{"heroId":"14","name":"\u4ea1\u7075\u6218\u795e","alias":"Sion","title":"\u8d5b\u6069","roles":["tank","fighter"],"isWeekFree":"0","attack":"5","defense":"9","magic":"3","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/14.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/14.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u4ea1\u7075\u6218\u795e,\u585e\u6069,\u8d5b\u6069,se,wlzs,Sion,wanglingzhanshen,saien"},{"heroId":"15","name":"\u6218\u4e89\u5973\u795e","alias":"Sivir","title":"\u5e0c\u7ef4\u5c14","roles":["marksman"],"isWeekFree":"0","attack":"9","defense":"3","magic":"1","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/15.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/15.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u6218\u4e89\u5973\u795e,\u8f6e\u5b50\u5988,\u5e0c\u7ef4\u5c14,lzm,xwe,zzns,Sivir,zhanzhengnvshen,lunzima,xiweier"},{"heroId":"16","name":"\u4f17\u661f\u4e4b\u5b50","alias":"Soraka","title":"\u7d22\u62c9\u5361","roles":["support","mage"],"isWeekFree":"0","attack":"2","defense":"5","magic":"7","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/16.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/16.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u4f17\u661f\u4e4b\u5b50,\u7d22\u62c9\u5361,\u661f\u5988,\u5976\u5988,xm,nm,slk,zxzz,Soraka,zhongxingzhizi,suolaka,xingma,naima"},{"heroId":"17","name":"\u8fc5\u6377\u65a5\u5019","alias":"Teemo","title":"\u63d0\u83ab","roles":["marksman","assassin"],"isWeekFree":"1","attack":"5","defense":"3","magic":"7","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/17.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/17.ogg","isARAMweekfree":"0","ispermanentweekfree":"1","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3500","camp":"","campId":"","keywords":"\u8fc5\u6377\u65a5\u5019,\u63d0\u83ab,timo,Teemo,tm,xjch,xunjiechihou,timo"},{"heroId":"18","name":"\u9ea6\u6797\u70ae\u624b","alias":"Tristana","title":"\u5d14\u4e1d\u5854\u5a1c","roles":["marksman","assassin"],"isWeekFree":"0","attack":"9","defense":"3","magic":"5","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/18.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/18.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"1000","camp":"","campId":"","keywords":"\u9ea6\u6797\u70ae\u624b,\u5c0f\u70ae,\u5d14\u4e1d\u5854\u5a1c,xp,cstn,mlps,Tristana,mailinpaoshou,xiaopao,cuisitana"},{"heroId":"19","name":"\u7956\u5b89\u6012\u517d","alias":"Warwick","title":"\u6c83\u91cc\u514b","roles":["fighter","tank"],"isWeekFree":"0","attack":"9","defense":"5","magic":"3","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/19.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/19.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u7956\u5b89\u6012\u517d,\u6c83\u91cc\u514b,\u72fc\u4eba,lr,wlk,zans,Warwick,zuannushou,wolike,langren"},{"heroId":"20","name":"\u96ea\u539f\u53cc\u5b50","alias":"Nunu","title":"\u52aa\u52aa\u548c\u5a01\u6717\u666e","roles":["tank","fighter"],"isWeekFree":"0","attack":"4","defense":"6","magic":"7","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/20.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/20.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u96ea\u539f\u53cc\u5b50,\u52aa\u52aa\u548c\u5a01\u6717\u666e,\u52aa\u52aa,\u96ea\u4eba,Nunu,nn,xr,xysz,mmhwlp,xueyuanshuangzi,nunuheweilangpu,nunu,xueren"},{"heroId":"21","name":"\u8d4f\u91d1\u730e\u4eba","alias":"MissFortune","title":"\u5384\u8fd0\u5c0f\u59d0","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"2","magic":"5","difficulty":"1","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/21.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/21.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u8d4f\u91d1\u730e\u4eba,\u8d4f\u91d1,\u5384\u8fd0\u5c0f\u59d0,MF,MissFortune,sj,sjlr,eyxj,shangjinlieren,shangjin,eyunxiaojie"},{"heroId":"22","name":"\u5bd2\u51b0\u5c04\u624b","alias":"Ashe","title":"\u827e\u5e0c","roles":["marksman","support"],"isWeekFree":"1","attack":"7","defense":"3","magic":"2","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/22.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/22.ogg","isARAMweekfree":"0","ispermanentweekfree":"1","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u827e\u5e0c,\u5bd2\u51b0,\u7231\u5c04,\u827e\u5c04,\u51b0\u5f13,Ashe,aixi,hanbing,aishe,aishe,binggong,ax,hb,as,bg"},{"heroId":"23","name":"\u86ee\u65cf\u4e4b\u738b","alias":"Tryndamere","title":"\u6cf0\u8fbe\u7c73\u5c14","roles":["fighter","assassin"],"isWeekFree":"0","attack":"10","defense":"5","magic":"2","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/23.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/23.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u86ee\u65cf\u4e4b\u738b,\u86ee\u738b,\u6cf0\u8fbe\u7c73\u5c14,Tryndamere,tdme,mw,mzzw,manzuzhiwang,manwang,taidamier"},{"heroId":"24","name":"\u6b66\u5668\u5927\u5e08","alias":"Jax","title":"\u8d3e\u514b\u65af","roles":["fighter","assassin"],"isWeekFree":"0","attack":"7","defense":"5","magic":"7","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/24.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/24.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u6b66\u5668\u5927\u5e08,\u8d3e\u514b\u65af,\u6b66\u5668,Jax,wq,jks,wqds,wuqidashi,jiakesi,wuqi"},{"heroId":"25","name":"\u5815\u843d\u5929\u4f7f","alias":"Morgana","title":"\u83ab\u7518\u5a1c","roles":["mage","support"],"isWeekFree":"0","attack":"1","defense":"6","magic":"8","difficulty":"1","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/25.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/25.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u5815\u843d\u5929\u4f7f,\u83ab\u7518\u5a1c,MGN,dlts,Morgana,duoluotianshi,moganna"},{"heroId":"26","name":"\u65f6\u5149\u5b88\u62a4\u8005","alias":"Zilean","title":"\u57fa\u5170","roles":["support","mage"],"isWeekFree":"0","attack":"2","defense":"5","magic":"8","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/26.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/26.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u65f6\u5149\u5b88\u62a4\u8005,\u57fa\u5170,Zilean,jl,sgshz,\u65f6\u5149\u8001\u4eba,\u65f6\u5149\u8001\u5934,shiguangshouhuzhe,jilan,shiguanglaoren,shiguanglaotou"},{"heroId":"27","name":"\u70bc\u91d1\u672f\u58eb","alias":"Singed","title":"\u8f9b\u5409\u5fb7","roles":["tank","fighter"],"isWeekFree":"0","attack":"4","defense":"8","magic":"7","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/27.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/27.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u70bc\u91d1\u672f\u58eb,\u8f9b\u5409\u5fb7,\u70bc\u91d1,lj,xjd,ljss,Singed,lianjinshushi,xinjide,lianjin"},{"heroId":"28","name":"\u75db\u82e6\u4e4b\u62e5","alias":"Evelynn","title":"\u4f0a\u8299\u7433","roles":["assassin","mage"],"isWeekFree":"0","attack":"4","defense":"2","magic":"7","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/28.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/28.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u75db\u82e6\u4e4b\u62e5,\u4f0a\u8299\u7433,\u5be1\u5987,Evelynn,tongkuzhiyong,yifulin,guafu,gf,tkzy,yfl"},{"heroId":"29","name":"\u761f\u75ab\u4e4b\u6e90","alias":"Twitch","title":"\u56fe\u5947","roles":["marksman","assassin"],"isWeekFree":"0","attack":"9","defense":"2","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/29.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/29.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u761f\u75ab\u4e4b\u6e90,\u56fe\u5947,\u8001\u9f20,Twitch,ls,tq,wyzy,wenyizhiyuan,tuqi,laoshu"},{"heroId":"30","name":"\u6b7b\u4ea1\u9882\u5531\u8005","alias":"Karthus","title":"\u5361\u5c14\u8428\u65af","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"2","magic":"10","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/30.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/30.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u6b7b\u4ea1\u9882\u5531\u8005,\u5361\u5c14\u8428\u65af,\u6b7b\u6b4c,Karthus,sg,kess,swscz,siwangsongchangzhe,kaersasi,sige"},{"heroId":"31","name":"\u865a\u7a7a\u6050\u60e7","alias":"Chogath","title":"\u79d1\u52a0\u65af","roles":["tank","mage"],"isWeekFree":"0","attack":"3","defense":"7","magic":"7","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/31.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/31.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"1500","camp":"","campId":"","keywords":"\u865a\u7a7a\u6050\u60e7,\u79d1\u52a0\u65af,\u5927\u866b\u5b50,\u866b\u5b50,Chogath,xukongkongju,kejiasi,dachongzi,chongzi,xkkj,kjs,dcz,cz"},{"heroId":"32","name":"\u6b87\u4e4b\u6728\u4e43\u4f0a","alias":"Amumu","title":"\u963f\u6728\u6728","roles":["tank","mage"],"isWeekFree":"0","attack":"2","defense":"6","magic":"8","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/32.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/32.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u963f\u6728\u6728,\u6728\u4e43\u4f0a,\u5206\u5934,\u6b87\u4e4b\u6728\u4e43\u4f0a,\u6728\u6728,\u4f24\u4e4b\u6728\u4e43\u4f0a,amumu,munaiyi,fentou,shangzhimunaiyi,amm,szmny,mny,ft,mm,mumu"},{"heroId":"33","name":"\u62ab\u7532\u9f99\u9f9f","alias":"Rammus","title":"\u62c9\u83ab\u65af","roles":["tank","fighter"],"isWeekFree":"1","attack":"4","defense":"10","magic":"5","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/33.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/33.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u62ab\u7532\u9f99\u9f9f,\u62c9\u83ab\u65af,\u9f99\u9f9f,lg,pjlg,lms,Rammus,pijialonggui,lamosi,longgui"},{"heroId":"34","name":"\u51b0\u6676\u51e4\u51f0","alias":"Anivia","title":"\u827e\u5c3c\u7ef4\u4e9a","roles":["mage","support"],"isWeekFree":"1","attack":"1","defense":"4","magic":"10","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/34.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/34.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u51e4\u51f0,\u51b0\u6676\u51e4\u51f0,\u827e\u5c3c\u7ef4\u4e9a,Anivia,fenghuang,bingjingfenghuang,ainiweiya,anwy,bjfh,fh"},{"heroId":"35","name":"\u6076\u9b54\u5c0f\u4e11","alias":"Shaco","title":"\u8428\u79d1","roles":["assassin"],"isWeekFree":"0","attack":"8","defense":"4","magic":"6","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/35.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/35.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2000","camp":"","campId":"","keywords":"\u6076\u9b54\u5c0f\u4e11,\u5c0f\u4e11,\u6c99\u6263,\u6c99\u53e3,\u8428\u79d1,xc,emxc,sk,emoxiaochou,xiaochou,sake,Shaco"},{"heroId":"36","name":"\u7956\u5b89\u72c2\u4eba","alias":"DrMundo","title":"\u8499\u591a\u533b\u751f","roles":["fighter","tank"],"isWeekFree":"0","attack":"5","defense":"7","magic":"6","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/36.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/36.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u7956\u5b89\u72c2\u4eba,\u8499\u591a\u533b\u751f,\u8499\u591a,DrMundo,zuankuangren,mengduoyisheng,mengduo,md,mdys,zakr"},{"heroId":"37","name":"\u7434\u745f\u4ed9\u5973","alias":"Sona","title":"\u5a11\u5a1c","roles":["support","mage"],"isWeekFree":"0","attack":"5","defense":"2","magic":"8","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/37.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/37.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u7434\u745f\u4ed9\u5973,\u7434\u5973,\u5a11\u5a1c,sn,qn,qsxn,Sona,qinsexiannv,qinnv,suona"},{"heroId":"38","name":"\u865a\u7a7a\u884c\u8005","alias":"Kassadin","title":"\u5361\u8428\u4e01","roles":["assassin","mage"],"isWeekFree":"0","attack":"3","defense":"5","magic":"8","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/38.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/38.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u865a\u7a7a\u884c\u8005,\u5361\u8428\u4e01,ksd,xkxz,Kassadin,xukongxingzhe,kasading"},{"heroId":"39","name":"\u5200\u950b\u821e\u8005","alias":"Irelia","title":"\u827e\u745e\u8389\u5a05","roles":["fighter","assassin"],"isWeekFree":"0","attack":"7","defense":"4","magic":"5","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/39.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/39.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4000","camp":"","campId":"","keywords":"\u5200\u950b\u821e\u8005,\u827e\u745e\u8389\u5a05,\u5973\u5200,\u5973\u5200\u950b,Irelia,nd,ndf,dfwz,arly,daofengwuzhe,airuiliya,nvdao,nvdaofeng"},{"heroId":"40","name":"\u98ce\u66b4\u4e4b\u6012","alias":"Janna","title":"\u8fe6\u5a1c","roles":["support","mage"],"isWeekFree":"1","attack":"3","defense":"5","magic":"7","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/40.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/40.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u98ce\u66b4\u4e4b\u6012,\u8fe6\u5a1c,\u98ce\u5973,fn,jn,fbzn,Janna,fengbaozhinu,jiana,fengnv"},{"heroId":"41","name":"\u6d77\u6d0b\u4e4b\u707e","alias":"Gangplank","title":"\u666e\u6717\u514b","roles":["fighter"],"isWeekFree":"1","attack":"7","defense":"6","magic":"4","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/41.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/41.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u6d77\u6d0b\u4e4b\u707e,\u666e\u6717\u514b,\u8239\u957f,plk,cz,hyzz,Gangplank,haiyangzhizai,pulangke,chuanzhang"},{"heroId":"42","name":"\u82f1\u52c7\u6295\u5f39\u624b","alias":"Corki","title":"\u5e93\u5947","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"3","magic":"6","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/42.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/42.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3500","camp":"","campId":"","keywords":"\u82f1\u52c7\u6295\u5f39\u624b,\u5e93\u5947,\u98de\u673a,Corki,yingyongtoudanshou,kuqi,feiji,fj,kq,yytds"},{"heroId":"43","name":"\u5929\u542f\u8005","alias":"Karma","title":"\u5361\u5c14\u739b","roles":["mage","support"],"isWeekFree":"0","attack":"1","defense":"7","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/43.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/43.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u5929\u542f\u8005,\u5361\u5c14\u739b,\u6247\u5b50\u5988,Karma,szm,kem,tqz,tianqizhe,kaerma,shanzima"},{"heroId":"44","name":"\u74e6\u6d1b\u5170\u4e4b\u76fe","alias":"Taric","title":"\u5854\u91cc\u514b","roles":["support","fighter"],"isWeekFree":"0","attack":"4","defense":"8","magic":"5","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/44.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/44.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"1500","camp":"","campId":"","keywords":"\u74e6\u6d1b\u5170\u4e4b\u76fe,\u5854\u91cc\u514b,\u5b9d\u77f3,bs,tlk,wllzd,Taric,waluolanzhidun,talike,baoshi"},{"heroId":"45","name":"\u90aa\u6076\u5c0f\u6cd5\u5e08","alias":"Veigar","title":"\u7ef4\u8fe6","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"2","magic":"10","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/45.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/45.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u90aa\u6076\u5c0f\u6cd5\u5e08,\u5c0f\u6cd5\u5e08,\u7ef4\u8fe6,xfs,xexfs,wj,Veigar,xieexiaofashi,xiaofashi,weijia"},{"heroId":"48","name":"\u5de8\u9b54\u4e4b\u738b","alias":"Trundle","title":"\u7279\u6717\u5fb7\u5c14","roles":["fighter","tank"],"isWeekFree":"0","attack":"7","defense":"6","magic":"2","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/48.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/48.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u5de8\u9b54\u4e4b\u738b,\u5de8\u9b54,\u7279\u6717\u5fb7\u5c14,Trundle,jm,jmzw,tlde,jumozhiwang,jumo,telangdeer"},{"heroId":"50","name":"\u8bfa\u514b\u8428\u65af\u7edf\u9886","alias":"Swain","title":"\u65af\u7ef4\u56e0","roles":["mage","fighter"],"isWeekFree":"0","attack":"2","defense":"6","magic":"9","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/50.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/50.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u8bfa\u514b\u8428\u65af\u7edf\u9886,\u4e4c\u9e26,\u65af\u7ef4\u56e0,swy,wy,nksstl,Swain,nuokesasitongling,wuya,siweiyin"},{"heroId":"51","name":"\u76ae\u57ce\u5973\u8b66","alias":"Caitlyn","title":"\u51ef\u7279\u7433","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"2","magic":"2","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/51.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/51.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3000","camp":"","campId":"","keywords":"\u76ae\u57ce\u5973\u8b66,\u51ef\u7279\u7433,\u5973\u8b66,\u76ae\u57ce,Caitlyn,pichengnvjing,kaitelin,nvjing,picheng,pc,nj,pcnj,ctl"},{"heroId":"53","name":"\u84b8\u6c7d\u673a\u5668\u4eba","alias":"Blitzcrank","title":"\u5e03\u91cc\u8328","roles":["tank","fighter","support"],"isWeekFree":"0","attack":"4","defense":"8","magic":"5","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/53.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/53.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u84b8\u6c7d\u673a\u5668\u4eba,\u5e03\u91cc\u8328,\u673a\u5668\u4eba,Blitzcrank,zhengqijiqiren,bulici,jiqiren,zqjqr,jqr,blc"},{"heroId":"54","name":"\u7194\u5ca9\u5de8\u517d","alias":"Malphite","title":"\u58a8\u83f2\u7279","roles":["tank","fighter"],"isWeekFree":"0","attack":"5","defense":"9","magic":"7","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/54.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/54.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"1000","camp":"","campId":"","keywords":"\u7194\u5ca9\u5de8\u517d,\u58a8\u83f2\u7279,\u77f3\u5934\u4eba,Malphite,str,mft,ryjs,rongyanjushou,mofeite,shitouren"},{"heroId":"55","name":"\u4e0d\u7965\u4e4b\u5203","alias":"Katarina","title":"\u5361\u7279\u7433\u5a1c","roles":["assassin","mage"],"isWeekFree":"0","attack":"4","defense":"3","magic":"9","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/55.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/55.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u4e0d\u7965\u4e4b\u5203,\u5361\u7279\u7433\u5a1c,\u5361\u7279,kt,ktln,bxzr,\u4e0d\u8be6,bx,Katarina,buxiangzhiren,katelinna,kate,buxiang"},{"heroId":"56","name":"\u6c38\u6052\u68a6\u9b47","alias":"Nocturne","title":"\u9b54\u817e","roles":["assassin","fighter"],"isWeekFree":"0","attack":"9","defense":"5","magic":"2","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/56.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/56.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u6c38\u6052\u68a6\u9b47,\u9b54\u817e,noc,Nocturne,\u68a6\u9b47,my,yhmy,mt,yonghengmengyan,moteng,mengyan"},{"heroId":"57","name":"\u626d\u66f2\u6811\u7cbe","alias":"Maokai","title":"\u8302\u51ef","roles":["tank","mage"],"isWeekFree":"0","attack":"3","defense":"8","magic":"6","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/57.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/57.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u626d\u66f2\u6811\u7cbe,\u8302\u51ef,\u5927\u6811,ds,mk,nqsj,Maokai,niuqushujing,maokai,dashu"},{"heroId":"58","name":"\u8352\u6f20\u5c60\u592b","alias":"Renekton","title":"\u96f7\u514b\u987f","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"5","magic":"2","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/58.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/58.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u8352\u6f20\u5c60\u592b,\u9cc4\u9c7c,\u96f7\u514b\u987f,ey,lkd,mmtf,huangmotufu,eyu,leikedun"},{"heroId":"59","name":"\u5fb7\u739b\u897f\u4e9a\u7687\u5b50","alias":"JarvanIV","title":"\u5609\u6587\u56db\u4e16","roles":["tank","fighter"],"isWeekFree":"0","attack":"6","defense":"8","magic":"3","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/59.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/59.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u5fb7\u739b\u897f\u4e9a\u7687\u5b50,\u5609\u6587\u56db\u4e16,\u7687\u5b50,\u5609\u6587,JarvanIV,jw,hz,dmxyhz,jwss,demaxiyahuangzi,jiawensishi,huangzi,jiawen"},{"heroId":"60","name":"\u8718\u86db\u5973\u7687","alias":"Elise","title":"\u4f0a\u8389\u4e1d","roles":["mage","fighter"],"isWeekFree":"1","attack":"6","defense":"5","magic":"7","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/60.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/60.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u8718\u86db\u5973\u7687,\u4f0a\u8389\u4e1d,\u8718\u86db,Elise,zz,zznh,yls,zhizhunvhuang,yilisi,zhizhu"},{"heroId":"61","name":"\u53d1\u6761\u9b54\u7075","alias":"Orianna","title":"\u5965\u8389\u5b89\u5a1c","roles":["mage","support"],"isWeekFree":"1","attack":"4","defense":"3","magic":"9","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/61.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/61.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3000","camp":"","campId":"","keywords":"\u53d1\u6761\u9b54\u7075,\u5965\u8389\u5b89\u5a1c,\u53d1\u6761,Orianna,ftml,ft,alan,fatiaomoling,aolianna,fatiao"},{"heroId":"62","name":"\u9f50\u5929\u5927\u5723","alias":"MonkeyKing","title":"\u5b59\u609f\u7a7a","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"5","magic":"2","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/62.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/62.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u9f50\u5929\u5927\u5723,\u5b59\u609f\u7a7a,MonkeyKing,\u7334\u5b50,hz,qtds,swk,qitiandasheng,sunwukong,houzi"},{"heroId":"63","name":"\u590d\u4ec7\u7130\u9b42","alias":"Brand","title":"\u5e03\u5170\u5fb7","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"2","magic":"9","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/63.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/63.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2000","camp":"","campId":"","keywords":"\u590d\u4ec7\u7130\u9b42,\u5e03\u5170\u5fb7,\u706b\u7537,Brand,fuchouyanhun,bulande,huonan,cfyh,bld,hn"},{"heroId":"64","name":"\u76f2\u50e7","alias":"LeeSin","title":"\u674e\u9752","roles":["fighter","assassin"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/64.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/64.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u76f2\u50e7,\u778e\u5b50,\u674e\u9752,lq,xz,ms,LeeSin,mangseng,xiazi,liqing"},{"heroId":"67","name":"\u6697\u591c\u730e\u624b","alias":"Vayne","title":"\u8587\u6069","roles":["marksman","assassin"],"isWeekFree":"0","attack":"10","defense":"1","magic":"1","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/67.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/67.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u6697\u591c\u730e\u624b,\u8587\u6069,vn,Vayne,ve,ayls,anyelieshou,weien"},{"heroId":"68","name":"\u673a\u68b0\u516c\u654c","alias":"Rumble","title":"\u5170\u535a","roles":["fighter","mage"],"isWeekFree":"0","attack":"3","defense":"6","magic":"8","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/68.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/68.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u673a\u68b0\u516c\u654c,\u5170\u535a,Rumble,lb,jxgd,jixiegongdi,lanbo"},{"heroId":"69","name":"\u9b54\u86c7\u4e4b\u62e5","alias":"Cassiopeia","title":"\u5361\u897f\u5965\u4f69\u5a05","roles":["mage"],"isWeekFree":"1","attack":"2","defense":"3","magic":"9","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/69.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/69.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u9b54\u86c7\u4e4b\u62e5,\u5361\u897f\u5965\u4f69\u5a05,\u86c7\u5973,Cassiopeia,moshezhiyong,kaxiaopeiya,shenv,mszy,kxapy,sn"},{"heroId":"72","name":"\u6c34\u6676\u5148\u950b","alias":"Skarner","title":"\u65af\u5361\u7eb3","roles":["fighter","tank"],"isWeekFree":"0","attack":"7","defense":"6","magic":"5","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/72.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/72.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u6c34\u6676\u5148\u950b,\u65af\u5361\u7eb3,skn,sjxf,\u874e\u5b50,xz,Skarner,shuijingxianfeng,sikana,xiezi"},{"heroId":"74","name":"\u5927\u53d1\u660e\u5bb6","alias":"Heimerdinger","title":"\u9ed1\u9ed8\u4e01\u683c","roles":["mage","support"],"isWeekFree":"0","attack":"2","defense":"6","magic":"8","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/74.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/74.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u5927\u53d1\u660e\u5bb6,\u9ed1\u9ed8\u4e01\u683c,\u5927\u5934,Heimerdinger,dt,dfmj,hmdg,dafamingjia,heimodingge,datou"},{"heroId":"75","name":"\u6c99\u6f20\u6b7b\u795e","alias":"Nasus","title":"\u5185\u745f\u65af","roles":["fighter","tank"],"isWeekFree":"0","attack":"7","defense":"5","magic":"6","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/75.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/75.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u6c99\u6f20\u6b7b\u795e,\u5185\u745f\u65af,\u72d7\u5934,gt,nss,smss,Nasus,shamosishen,neisesi,goutou"},{"heroId":"76","name":"\u72c2\u91ce\u5973\u730e\u624b","alias":"Nidalee","title":"\u5948\u5fb7\u4e3d","roles":["assassin","mage"],"isWeekFree":"0","attack":"5","defense":"4","magic":"7","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/76.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/76.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3500","camp":"","campId":"","keywords":"\u72c2\u91ce\u5973\u730e\u624b,\u5948\u5fb7\u4e3d,\u8c79\u5973,bn,ndl,kynls,Nidalee,kuangyenvlieshou,naideli,baonv"},{"heroId":"77","name":"\u517d\u7075\u884c\u8005","alias":"Udyr","title":"\u4e4c\u8fea\u5c14","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"7","magic":"4","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/77.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/77.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u517d\u7075\u884c\u8005,\u4e4c\u8fea\u5c14,Udyr,wde,slxz,UD,shoulingxingzhe,wudier"},{"heroId":"78","name":"\u5723\u9524\u4e4b\u6bc5","alias":"Poppy","title":"\u6ce2\u6bd4","roles":["tank","fighter"],"isWeekFree":"0","attack":"6","defense":"7","magic":"2","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/78.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/78.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"450","couponPrice":"1000","camp":"","campId":"","keywords":"\u5723\u9524\u4e4b\u6bc5,\u6ce2\u6bd4,bb,sczy,Poppy,shengchuizhiyi,bobi"},{"heroId":"79","name":"\u9152\u6876","alias":"Gragas","title":"\u53e4\u62c9\u52a0\u65af","roles":["fighter","mage"],"isWeekFree":"0","attack":"4","defense":"7","magic":"6","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/79.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/79.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u9152\u6876,\u53e4\u62c9\u52a0\u65af,\u5564\u9152\u4eba,\u8089\u86cb\u8471\u9e21,Gragas,pjr,jt,gljs,rdcj,jiutong,gulajiasi,pijiuren,roudancongji"},{"heroId":"80","name":"\u4e0d\u5c48\u4e4b\u67aa","alias":"Pantheon","title":"\u6f58\u68ee","roles":["fighter","assassin"],"isWeekFree":"0","attack":"9","defense":"4","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/80.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/80.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"1500","camp":"","campId":"","keywords":"\u4e0d\u5c48\u4e4b\u67aa,\u6f58\u68ee,Pantheon,PS,bqzq,buquzhiqiang,pansen"},{"heroId":"81","name":"\u63a2\u9669\u5bb6","alias":"Ezreal","title":"\u4f0a\u6cfd\u745e\u5c14","roles":["marksman","mage"],"isWeekFree":"0","attack":"7","defense":"2","magic":"6","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/81.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/81.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u63a2\u9669\u5bb6,\u4f0a\u6cfd\u745e\u5c14,ez,Ezreal,tanxianjia,yizeruier,txj,yzrr"},{"heroId":"82","name":"\u94c1\u94e0\u51a5\u9b42","alias":"Mordekaiser","title":"\u83ab\u5fb7\u51ef\u6492","roles":["fighter"],"isWeekFree":"0","attack":"4","defense":"6","magic":"7","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/82.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/82.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"1500","camp":"","campId":"","keywords":"\u94c1\u94e0\u51a5\u9b42,\u83ab\u5fb7\u51ef\u6492,\u94c1\u7537,Mordekaiser,tn,mdks,tkmh,tiekaiminghun,modekaisa,tienan"},{"heroId":"83","name":"\u7267\u9b42\u4eba","alias":"Yorick","title":"\u7ea6\u91cc\u514b","roles":["fighter","tank"],"isWeekFree":"0","attack":"6","defense":"6","magic":"4","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/83.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/83.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u7267\u9b42\u4eba,\u7ea6\u91cc\u514b,\u6398\u5893\u4eba,jmr,mhr,ylk,Yorick,muhunren,yuelike,juemuren"},{"heroId":"84","name":"\u79bb\u7fa4\u4e4b\u523a","alias":"Akali","title":"\u963f\u5361\u4e3d","roles":["assassin"],"isWeekFree":"0","attack":"5","defense":"3","magic":"8","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/84.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/84.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u963f\u5361\u4e3d,\u79bb\u7fa4\u4e4b\u523a,akali,liqunzhici,akl,lqzc"},{"heroId":"85","name":"\u72c2\u66b4\u4e4b\u5fc3","alias":"Kennen","title":"\u51ef\u5357","roles":["mage","marksman"],"isWeekFree":"0","attack":"6","defense":"4","magic":"7","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/85.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/85.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2500","camp":"","campId":"","keywords":"\u72c2\u66b4\u4e4b\u5fc3,\u51ef\u5357,kn,kbzx,Kennen,kuangbaozhixin,kainan"},{"heroId":"86","name":"\u5fb7\u739b\u897f\u4e9a\u4e4b\u529b","alias":"Garen","title":"\u76d6\u4f26","roles":["fighter","tank"],"isWeekFree":"1","attack":"7","defense":"7","magic":"1","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/86.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/86.ogg","isARAMweekfree":"0","ispermanentweekfree":"1","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"1000","camp":"","campId":"","keywords":"\u5fb7\u739b\u897f\u4e9a\u4e4b\u529b,\u76d6\u4f26,\u5927\u5b9d\u5251,Garen,dbj,gl,dmxyzl,demaxiyazhili,gailun,dabaojian"},{"heroId":"89","name":"\u66d9\u5149\u5973\u795e","alias":"Leona","title":"\u857e\u6b27\u5a1c","roles":["tank","support"],"isWeekFree":"0","attack":"4","defense":"8","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/89.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/89.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u66d9\u5149\u5973\u795e,\u857e\u6b27\u5a1c,\u65e5\u5973,\u66d9\u5149,\u5973\u5766,nt,rn,sg,lon,sgns,shuguangnvshen,leiouna,rinv,shuguang,Leona,nvtan"},{"heroId":"90","name":"\u865a\u7a7a\u5148\u77e5","alias":"Malzahar","title":"\u739b\u5c14\u624e\u54c8","roles":["mage","assassin"],"isWeekFree":"0","attack":"2","defense":"2","magic":"9","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/90.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/90.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u865a\u7a7a\u5148\u77e5,\u739b\u5c14\u624e\u54c8,\u8682\u86b1,\u9a6c\u5c14\u624e\u54c8,Malzahar,mz,mezh,xkxz,xukongxianzhi,maerzhaha,mazha,maerzhaha"},{"heroId":"91","name":"\u5200\u950b\u4e4b\u5f71","alias":"Talon","title":"\u6cf0\u9686","roles":["assassin"],"isWeekFree":"0","attack":"9","defense":"3","magic":"1","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/91.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/91.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5200\u950b\u4e4b\u5f71,\u7537\u5200,\u6cf0\u9686,tl,nd,dfzy,Talon,daofengzhiying,nandao,tailong"},{"heroId":"92","name":"\u653e\u9010\u4e4b\u5203","alias":"Riven","title":"\u9510\u96ef","roles":["fighter","assassin"],"isWeekFree":"0","attack":"8","defense":"5","magic":"1","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/92.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/92.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u653e\u9010\u4e4b\u5203,\u9510\u96ef,Riven,rw,fzzr,fangzhuzhiren,ruiwen"},{"heroId":"96","name":"\u6df1\u6e0a\u5de8\u53e3","alias":"KogMaw","title":"\u514b\u683c\u83ab","roles":["marksman","mage"],"isWeekFree":"0","attack":"8","defense":"2","magic":"5","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/96.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/96.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2000","camp":"","campId":"","keywords":"\u6df1\u6e0a\u5de8\u53e3,\u514b\u683c\u83ab,\u5927\u5634,KogMaw,dz,kgm,syjk,shenyuanjukou,kegemo,dazui"},{"heroId":"98","name":"\u66ae\u5149\u4e4b\u773c","alias":"Shen","title":"\u614e","roles":["tank"],"isWeekFree":"0","attack":"3","defense":"9","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/98.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/98.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"1350","couponPrice":"2000","camp":"","campId":"","keywords":"\u66ae\u5149\u4e4b\u773c,\u614e,yaozi,s,mgzy,Shen,muguangzhiyan,shen"},{"heroId":"99","name":"\u5149\u8f89\u5973\u90ce","alias":"Lux","title":"\u62c9\u514b\u4e1d","roles":["mage","support"],"isWeekFree":"0","attack":"2","defense":"4","magic":"9","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/99.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/99.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"3150","couponPrice":"2500","camp":"","campId":"","keywords":"\u5149\u8f89\u5973\u90ce,\u62c9\u514b\u4e1d,\u5149\u8f89,lux,lks,gh,ghnl,guanghuinvlang,lakesi,guanghui"},{"heroId":"101","name":"\u8fdc\u53e4\u5deb\u7075","alias":"Xerath","title":"\u6cfd\u62c9\u65af","roles":["mage"],"isWeekFree":"1","attack":"1","defense":"3","magic":"10","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/101.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/101.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2500","camp":"","campId":"","keywords":"\u8fdc\u53e4\u5deb\u7075,\u6cfd\u62c9\u65af,guancaiban,gbc,zls,ygwl,Xerath,yuanguwuling,zelasi"},{"heroId":"102","name":"\u9f99\u8840\u6b66\u59ec","alias":"Shyvana","title":"\u5e0c\u74e6\u5a1c","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"6","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/102.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/102.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u9f99\u8840\u6b66\u59ec,\u9f99\u5973,\u5e0c\u74e6\u5a1c,ln,xwn,lxwj,Shyvana,longxuewuji,longnv,xiwana"},{"heroId":"103","name":"\u4e5d\u5c3e\u5996\u72d0","alias":"Ahri","title":"\u963f\u72f8","roles":["mage","assassin"],"isWeekFree":"0","attack":"3","defense":"4","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/103.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/103.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3500","camp":"","campId":"","keywords":"\u4e5d\u5c3e,\u4e5d\u5c3e\u5996\u72d0,\u72d0\u72f8,\u963f\u72f8,jiuwei,jiuweiyaohu,huli,ali,ahri,jwyh,al,hl,jw"},{"heroId":"104","name":"\u6cd5\u5916\u72c2\u5f92","alias":"Graves","title":"\u683c\u96f7\u798f\u65af","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/104.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/104.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6cd5\u5916\u72c2\u5f92,\u683c\u96f7\u798f\u65af,\u7537\u67aa,Graves,nq,glfs,fwkt,fawaikuangtu,geleifusi,nanqiang"},{"heroId":"105","name":"\u6f6e\u6c50\u6d77\u7075","alias":"Fizz","title":"\u83f2\u5179","roles":["assassin","fighter"],"isWeekFree":"0","attack":"6","defense":"4","magic":"7","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/105.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/105.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6f6e\u6c50\u6d77\u7075,\u83f2\u5179,\u5c0f\u9c7c\u4eba,Fizz,fz,xyr,cxhl,chaoxihailing,feizi,xiaoyuren"},{"heroId":"106","name":"\u4e0d\u706d\u72c2\u96f7","alias":"Volibear","title":"\u6c83\u5229\u8d1d\u5c14","roles":["fighter","tank"],"isWeekFree":"0","attack":"7","defense":"7","magic":"4","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/106.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/106.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u4e0d\u706d\u72c2\u96f7,\u6c83\u5229\u8d1d\u5c14,Volibear,\u72d7\u718a,gx,wlbe,bmkl,bumiekuanglei,wolibeier,gouxiong"},{"heroId":"107","name":"\u50b2\u4e4b\u8ffd\u730e\u8005","alias":"Rengar","title":"\u96f7\u6069\u52a0\u5c14","roles":["assassin","fighter"],"isWeekFree":"0","attack":"7","defense":"4","magic":"2","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/107.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/107.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u50b2\u4e4b\u8ffd\u730e\u8005,\u72ee\u5b50\u72d7,\u96f7\u6069\u52a0\u5c14,szg,leje,azzlz,Rengar,aozhizhuiliezhe,shizigou,leienjiaer"},{"heroId":"110","name":"\u60e9\u6212\u4e4b\u7bad","alias":"Varus","title":"\u97e6\u9c81\u65af","roles":["marksman","mage"],"isWeekFree":"0","attack":"7","defense":"3","magic":"4","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/110.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/110.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u60e9\u6212\u4e4b\u7bad,\u97e6\u9c81\u65af,\u7ef4\u9c81\u65af,wls,cjzj,Varus,chengjiezhijian,weilusi"},{"heroId":"111","name":"\u6df1\u6d77\u6cf0\u5766","alias":"Nautilus","title":"\u8bfa\u63d0\u52d2\u65af","roles":["tank","fighter"],"isWeekFree":"0","attack":"4","defense":"6","magic":"6","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/111.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/111.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u6df1\u6d77\u6cf0\u5766,\u8bfa\u63d0\u52d2\u65af,\u6cf0\u5766,Nautilus,tt,ntls,shtt,shenhaitaitan,nuotileisi,taitan"},{"heroId":"112","name":"\u673a\u68b0\u5148\u9a71","alias":"Viktor","title":"\u7ef4\u514b\u6258","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"4","magic":"10","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/112.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/112.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"2500","camp":"","campId":"","keywords":"\u673a\u68b0\u5148\u9a71,\u7ef4\u514b\u6258,\u4e09\u53ea\u624b,szs,wkt,jxxq,Viktor,jixiexianqu,weiketuo,sanzhishou"},{"heroId":"113","name":"\u5317\u5730\u4e4b\u6012","alias":"Sejuani","title":"\u745f\u5e84\u59ae","roles":["tank","fighter"],"isWeekFree":"1","attack":"5","defense":"7","magic":"6","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/113.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/113.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u5317\u5730\u4e4b\u6012,\u732a\u59b9,\u745f\u5e84\u59ae,zm,szn,bdzn,Sejuani,beidizhinu,zhumei,sezhuangni"},{"heroId":"114","name":"\u65e0\u53cc\u5251\u59ec","alias":"Fiora","title":"\u83f2\u5965\u5a1c","roles":["fighter","assassin"],"isWeekFree":"0","attack":"10","defense":"4","magic":"2","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/114.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/114.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u65e0\u53cc\u5251\u59ec,\u83f2\u5965\u5a1c,\u5251\u59ec,Fiora,jj,wsjj,fan,wushuangjianji,feiaona,jianji"},{"heroId":"115","name":"\u7206\u7834\u9b3c\u624d","alias":"Ziggs","title":"\u5409\u683c\u65af","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"4","magic":"9","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/115.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/115.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u7206\u7834\u9b3c\u624d,\u70b8\u5f39\u4eba,\u5409\u683c\u65af,Ziggs,jgs,zdr,bpgc,baopoguicai,zhadanren,jigesi"},{"heroId":"117","name":"\u4ed9\u7075\u5973\u5deb","alias":"Lulu","title":"\u7490\u7490","roles":["support","mage"],"isWeekFree":"0","attack":"4","defense":"5","magic":"7","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/117.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/117.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u4ed9\u7075\u5973\u5deb,\u7490\u7490,ll,xlnw,Lulu,xianlingnvwu,lulu"},{"heroId":"119","name":"\u8363\u8000\u884c\u5211\u5b98","alias":"Draven","title":"\u5fb7\u83b1\u6587","roles":["marksman"],"isWeekFree":"0","attack":"9","defense":"3","magic":"1","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/119.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/119.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8363\u8000\u884c\u5211\u5b98,\u5fb7\u83b1\u6587,Draven,rongyaoxingxingguan,delaiwen,ryxxg,dlw"},{"heroId":"120","name":"\u6218\u4e89\u4e4b\u5f71","alias":"Hecarim","title":"\u8d6b\u5361\u91cc\u59c6","roles":["fighter","tank"],"isWeekFree":"1","attack":"8","defense":"6","magic":"4","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/120.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/120.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u6218\u4e89\u4e4b\u5f71,\u8d6b\u5361\u91cc\u59c6,\u4eba\u9a6c,Hecarim,rm,zzzy,hlkm,zhanzhengzhiying,hekalimu,renma"},{"heroId":"121","name":"\u865a\u7a7a\u63a0\u593a\u8005","alias":"Khazix","title":"\u5361\u5179\u514b","roles":["assassin"],"isWeekFree":"0","attack":"9","defense":"4","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/121.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/121.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u865a\u7a7a\u63a0\u593a\u8005,\u87b3\u8782,\u5361\u5179\u514b,kzk,tl,xkldz,Khazix,xukonglueduozhe,tanglang,kazike"},{"heroId":"122","name":"\u8bfa\u514b\u8428\u65af\u4e4b\u624b","alias":"Darius","title":"\u5fb7\u83b1\u5384\u65af","roles":["fighter","tank"],"isWeekFree":"0","attack":"9","defense":"5","magic":"1","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/122.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/122.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8bfa\u514b\u8428\u65af\u4e4b\u624b,\u5fb7\u83b1\u5384\u65af,\u8bfa\u624b,Darius,nuokesasizhishou,delaiesi,nuoshou,nksszs,ns,dles"},{"heroId":"126","name":"\u672a\u6765\u5b88\u62a4\u8005","alias":"Jayce","title":"\u6770\u65af","roles":["fighter","marksman"],"isWeekFree":"0","attack":"8","defense":"4","magic":"3","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/126.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/126.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u672a\u6765\u5b88\u62a4\u8005,\u6770\u65af,Jayce,js,wlshz,weilaishouhuzhe,jiesi"},{"heroId":"127","name":"\u51b0\u971c\u5973\u5deb","alias":"Lissandra","title":"\u4e3d\u6851\u5353","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"5","magic":"8","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/127.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/127.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"3000","camp":"","campId":"","keywords":"\u51b0\u971c\u5973\u5deb,\u51b0\u5973,\u4e3d\u6851\u5353,Lissandra,bn,lsz,bsnw,bingshuangnvwu,bingnv,lisangzhuo"},{"heroId":"131","name":"\u768e\u6708\u5973\u795e","alias":"Diana","title":"\u9edb\u5b89\u5a1c","roles":["fighter","mage"],"isWeekFree":"1","attack":"7","defense":"6","magic":"8","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/131.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/131.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u768e\u6708\u5973\u795e,\u9edb\u5b89\u5a1c,\u768e\u6708,Diana,jiaoyuenvshen,daianna,jiaoyue,jy,dan,jyns"},{"heroId":"133","name":"\u5fb7\u739b\u897f\u4e9a\u4e4b\u7ffc","alias":"Quinn","title":"\u594e\u56e0","roles":["marksman","assassin"],"isWeekFree":"0","attack":"9","defense":"4","magic":"2","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/133.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/133.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5fb7\u739b\u897f\u4e9a\u4e4b\u7ffc,\u594e\u56e0,\u9e1f\u4eba,ky,dmxyzz,Quinn,nr,demaxiyazhiyi,kuiyin,niaoren"},{"heroId":"134","name":"\u6697\u9ed1\u5143\u9996","alias":"Syndra","title":"\u8f9b\u5fb7\u62c9","roles":["mage","support"],"isWeekFree":"0","attack":"2","defense":"3","magic":"9","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/134.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/134.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6697\u9ed1\u5143\u9996,\u7403\u5973,\u8f9b\u5fb7\u62c9,qn,xdl,ahyy,Syndra,anheiyuanshou,qiunv,xindela"},{"heroId":"136","name":"\u94f8\u661f\u9f99\u738b","alias":"AurelionSol","title":"\u5965\u745e\u5229\u5b89\u7d22\u5c14","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"3","magic":"8","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/136.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/136.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u94f8\u661f\u9f99\u738b,\u5965\u745e\u5229\u5b89\u7d22\u5c14,\u7d22\u5c14,\u9f99\u738b,AurelionSol,zhuxinglongwang,aoruiliansuoer,suoer,longwang,zxlw,lw,se,arlasr"},{"heroId":"141","name":"\u5f71\u6d41\u4e4b\u9570","alias":"Kayn","title":"\u51ef\u9690","roles":["fighter","assassin"],"isWeekFree":"0","attack":"10","defense":"6","magic":"1","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/141.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/141.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5f71\u6d41\u4e4b\u9570,\u51ef\u9690,ky,ylzl,Kayn,yingliuzhilian,kaiyin"},{"heroId":"142","name":"\u66ae\u5149\u661f\u7075","alias":"Zoe","title":"\u4f50\u4f0a","roles":["mage","support"],"isWeekFree":"0","attack":"1","defense":"7","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/142.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/142.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u66ae\u5149\u661f\u7075,\u4f50\u4f0a,zy,mgxl,Zoe,muguangxingling,zuoyi"},{"heroId":"143","name":"\u8346\u68d8\u4e4b\u5174","alias":"Zyra","title":"\u5a55\u62c9","roles":["mage","support"],"isWeekFree":"0","attack":"4","defense":"3","magic":"8","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/143.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/143.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u8346\u68d8\u4e4b\u5174,\u5a55\u62c9,jl,jjzx,Zyra,jingjizhixing,jiela"},{"heroId":"145","name":"\u865a\u7a7a\u4e4b\u5973","alias":"Kaisa","title":"\u5361\u838e","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/145.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/145.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u865a\u7a7a\u4e4b\u5973,\u5361\u838e,ks,xkzn,Kaisa,xukongzhinv,kasha"},{"heroId":"147","name":"\u661f\u7c41\u6b4c\u59ec","alias":"Seraphine","title":"\u8428\u52d2\u82ac\u59ae","roles":["mage","support"],"isWeekFree":"0","attack":"0","defense":"0","magic":"0","difficulty":"0","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/147.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/147.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8428\u52d2\u82ac\u59ae,\u661f\u7c41\u6b4c\u59ec,Seraphine,saleifenni,xinglaigeji"},{"heroId":"150","name":"\u8ff7\u5931\u4e4b\u7259","alias":"Gnar","title":"\u7eb3\u5c14","roles":["fighter","tank"],"isWeekFree":"0","attack":"6","defense":"5","magic":"5","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/150.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/150.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8ff7\u5931\u4e4b\u7259,\u7eb3\u5c14,Gnar,ne,mszy,mishizhiya,naer"},{"heroId":"154","name":"\u751f\u5316\u9b54\u4eba","alias":"Zac","title":"\u624e\u514b","roles":["tank","fighter"],"isWeekFree":"0","attack":"3","defense":"7","magic":"7","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/154.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/154.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3000","camp":"","campId":"","keywords":"\u751f\u5316\u9b54\u4eba,\u624e\u514b,Zac,shenghuamoren,zhake,zk,shmr"},{"heroId":"157","name":"\u75be\u98ce\u5251\u8c6a","alias":"Yasuo","title":"\u4e9a\u7d22","roles":["fighter","assassin"],"isWeekFree":"0","attack":"8","defense":"4","magic":"4","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/157.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/157.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u75be\u98ce\u5251\u8c6a,\u5251\u8c6a,\u4e9a\u7d22,Yasuo,ys,jh,jfjh,jifengjianhao,jianhao,yasuo"},{"heroId":"161","name":"\u865a\u7a7a\u4e4b\u773c","alias":"Velkoz","title":"\u7ef4\u514b\u5179","roles":["mage"],"isWeekFree":"0","attack":"2","defense":"2","magic":"10","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/161.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/161.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u865a\u7a7a\u4e4b\u773c,\u5927\u773c,\u7ef4\u514b\u5179,wkz,dy,xkzy,Velkoz,xukongzhiyan,dayan,weikezi"},{"heroId":"163","name":"\u5ca9\u96c0","alias":"Taliyah","title":"\u5854\u8389\u57ad","roles":["mage","support"],"isWeekFree":"0","attack":"1","defense":"7","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/163.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/163.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5ca9\u96c0,\u5c0f\u9e1f,\u5854\u8389\u57ad,tly,xn,yq,Taliyah,yanque,xiaoniao,taliya"},{"heroId":"164","name":"\u9752\u94a2\u5f71","alias":"Camille","title":"\u5361\u871c\u5c14","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"6","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/164.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/164.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u9752\u94a2\u5f71,\u5361\u871c\u5c14,\u5361\u5bc6\u5c14,Camille,\u817f\u5973,qinggangying,kamier,kamier,tuinv,qgy,kme,tn"},{"heroId":"166","name":"\u5f71\u54e8","alias":"Akshan","title":"\u963f\u514b\u5c1a","roles":["marksman","assassin"],"isWeekFree":"1","attack":"0","defense":"0","magic":"0","difficulty":"0","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/166.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/166.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5f71\u54e8,\u963f\u514b\u5c1a,\u963f\u514b,\u963f,yingshao,akeshang,ake,a"},{"heroId":"201","name":"\u5f17\u96f7\u5c14\u5353\u5fb7\u4e4b\u5fc3","alias":"Braum","title":"\u5e03\u9686","roles":["support","tank"],"isWeekFree":"1","attack":"3","defense":"9","magic":"4","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/201.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/201.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5f17\u96f7\u5c14\u5353\u5fb7\u4e4b\u5fc3,\u5e03\u9686,bl,Braum,flezdzx,fuleierzhuodezhixin,bulong"},{"heroId":"202","name":"\u620f\u547d\u5e08","alias":"Jhin","title":"\u70ec","roles":["marksman","mage"],"isWeekFree":"0","attack":"10","defense":"2","magic":"6","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/202.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/202.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u620f\u547d\u5e08,\u70ec,Jhin,j,xms,ximingshi,jin"},{"heroId":"203","name":"\u6c38\u730e\u53cc\u5b50","alias":"Kindred","title":"\u5343\u73cf","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"2","magic":"2","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/203.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/203.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6c38\u730e\u53cc\u5b50,\u5343\u73cf,Kindred,qj,ylsz,yonglieshuangzi,qianjue"},{"heroId":"221","name":"\u7956\u5b89\u82b1\u706b","alias":"Zeri","title":"\u6cfd\u4e3d","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/221.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/221.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"7800","couponPrice":"4500","camp":"","campId":"","keywords":""},{"heroId":"222","name":"\u66b4\u8d70\u841d\u8389","alias":"Jinx","title":"\u91d1\u514b\u4e1d","roles":["marksman"],"isWeekFree":"0","attack":"9","defense":"2","magic":"4","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/222.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/222.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u66b4\u8d70\u841d\u8389,\u841d\u8389,\u91d1\u514b\u4e1d,Jinx,jks,ll,bzll,baozouluoli,luoli,jinkesi,\u91d1\u514b\u4e1d"},{"heroId":"223","name":"\u6cb3\u6d41\u4e4b\u738b","alias":"TahmKench","title":"\u5854\u59c6","roles":["support","tank"],"isWeekFree":"0","attack":"3","defense":"9","magic":"6","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/223.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/223.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6cb3\u6d41\u4e4b\u738b,hama,\u5854\u59c6,tm,hlzw,TahmKench,heliuzhiwang,tamu"},{"heroId":"234","name":"\u7834\u8d25\u4e4b\u738b","alias":"Viego","title":"\u4f5b\u8036\u6208","roles":["assassin","fighter"],"isWeekFree":"0","attack":"6","defense":"4","magic":"2","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/234.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/234.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u7834\u8d25\u4e4b\u738b,\u4f5b\u8036\u6208,\u7834\u8d25,\u4f5b,pobaizhiwang,fuyege,pobai,fu"},{"heroId":"235","name":"\u6da4\u9b42\u5723\u67aa","alias":"Senna","title":"\u8d5b\u5a1c","roles":["marksman","support"],"isWeekFree":"0","attack":"7","defense":"2","magic":"6","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/235.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/235.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6da4\u9b42\u5723\u67aa,\u8d5b\u5a1c,\u5976\u67aa,Senna,nq,sn,qhsq,dihunshengqiang,saina,naiqiang"},{"heroId":"236","name":"\u5723\u67aa\u6e38\u4fa0","alias":"Lucian","title":"\u5362\u9521\u5b89","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/236.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/236.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5723\u67aa\u6e38\u4fa0,\u5362\u9521\u5b89,\u5965\u5df4\u9a6c,Lucian,abm,lxa,sqyx,shengqiangyouxia,luxian,aobama"},{"heroId":"238","name":"\u5f71\u6d41\u4e4b\u4e3b","alias":"Zed","title":"\u52ab","roles":["assassin"],"isWeekFree":"0","attack":"9","defense":"2","magic":"1","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/238.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/238.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5f71\u6d41\u4e4b\u4e3b,\u52ab,j,ylzz,Zed,yingliuzhizhu,jie"},{"heroId":"240","name":"\u66b4\u6012\u9a91\u58eb","alias":"Kled","title":"\u514b\u70c8","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"2","magic":"2","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/240.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/240.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u66b4\u6012\u9a91\u58eb,\u514b\u70c8,kl,bnqs,baonuqishi,kelie"},{"heroId":"245","name":"\u65f6\u95f4\u523a\u5ba2","alias":"Ekko","title":"\u827e\u514b","roles":["assassin","fighter"],"isWeekFree":"0","attack":"5","defense":"3","magic":"7","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/245.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/245.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u65f6\u95f4\u523a\u5ba2,\u827e\u514b,Ekko,shijiancike,aike,ak,sjck"},{"heroId":"246","name":"\u5143\u7d20\u5973\u7687","alias":"Qiyana","title":"\u5947\u4e9a\u5a1c","roles":["assassin","fighter"],"isWeekFree":"0","attack":"0","defense":"2","magic":"4","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/246.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/246.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5143\u7d20\u5973\u7687,\u5947\u4e9a\u5a1c,qyn,ysnh,Qiyana,yuansunvhuang,qiyana"},{"heroId":"254","name":"\u76ae\u57ce\u6267\u6cd5\u5b98","alias":"Vi","title":"\u851a","roles":["fighter","assassin"],"isWeekFree":"0","attack":"8","defense":"5","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/254.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/254.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u76ae\u57ce\u6267\u6cd5\u5b98,\u62f3\u5973,\u851a,v,qv,pczfg,Vi,pichengzhifaguan,quannv,wei"},{"heroId":"266","name":"\u6697\u88d4\u5251\u9b54","alias":"Aatrox","title":"\u4e9a\u6258\u514b\u65af","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"4","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/266.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/266.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5251\u9b54,\u4e9a\u6258\u514b\u65af,\u6697\u88d4\u5251\u9b54,jianmo,yatuokesi,anyijianmo,Aatrox,jm,ayjm,ytks"},{"heroId":"267","name":"\u5524\u6f6e\u9c9b\u59ec","alias":"Nami","title":"\u5a1c\u7f8e","roles":["support","mage"],"isWeekFree":"0","attack":"4","defense":"3","magic":"7","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/267.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/267.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"4800","couponPrice":"3500","camp":"","campId":"","keywords":"\u5524\u6f6e\u9c9b\u59ec,\u9c9b\u59ec,\u5a1c\u7f8e,nm,jj,hcjj,Nami,huanchaojiaoji,jiaoji,namei"},{"heroId":"268","name":"\u6c99\u6f20\u7687\u5e1d","alias":"Azir","title":"\u963f\u5179\u5c14","roles":["mage","marksman"],"isWeekFree":"0","attack":"6","defense":"3","magic":"8","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/268.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/268.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6c99\u6f20\u7687\u5e1d,\u963f\u5179\u5c14,\u6c99\u7687,Azir,shamohuangdi,azier,shahuang,smhd,aze,sh"},{"heroId":"350","name":"\u9b54\u6cd5\u732b\u54aa","alias":"Yuumi","title":"\u60a0\u7c73","roles":["support","mage"],"isWeekFree":"0","attack":"5","defense":"1","magic":"8","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/350.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/350.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u9b54\u6cd5\u732b\u54aa,\u732b,\u732b\u54aa,\u60a0\u7c73,cat,m,mm,mfmm,ym,Yuumi,mofamaomi,mao,maomi,youmi"},{"heroId":"360","name":"\u6c99\u6f20\u73ab\u7470","alias":"Samira","title":"\u838e\u5f25\u62c9","roles":["marksman"],"isWeekFree":"1","attack":"8","defense":"5","magic":"3","difficulty":"6","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/360.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/360.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u838e\u5f25\u62c9,\u6c99\u6f20\u73ab\u7470,Samira,sml,smmg,shamila,shamomeigui"},{"heroId":"412","name":"\u9b42\u9501\u5178\u72f1\u957f","alias":"Thresh","title":"\u9524\u77f3","roles":["support","fighter"],"isWeekFree":"0","attack":"5","defense":"6","magic":"6","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/412.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/412.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u9b42\u9501\u5178\u72f1\u957f,\u9524\u77f3,Thresh,cs,hsdyz,hunsuodianyuzhang,chuishi"},{"heroId":"420","name":"\u6d77\u517d\u796d\u53f8","alias":"Illaoi","title":"\u4fc4\u6d1b\u4f0a","roles":["fighter","tank"],"isWeekFree":"1","attack":"8","defense":"6","magic":"3","difficulty":"4","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/420.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/420.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6d77\u517d\u796d\u53f8,\u4fc4\u6d1b\u4f0a,\u89e6\u624b\u5988,Illaoi,csm,ely,hsjs,haishoujisi,eluoyi,chushouma"},{"heroId":"421","name":"\u865a\u7a7a\u9041\u5730\u517d","alias":"RekSai","title":"\u96f7\u514b\u585e","roles":["fighter"],"isWeekFree":"0","attack":"8","defense":"5","magic":"2","difficulty":"3","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/421.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/421.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u865a\u7a7a\u9041\u5730\u517d,\u6316\u6398\u673a,\u96f7\u514b\u8d5b,\u96f7\u514b\u585e,lks,wjj,xkdds,RekSai,xukongdundishou,wajueji,leikesai,leikesai"},{"heroId":"427","name":"\u7fe0\u795e","alias":"Ivern","title":"\u827e\u7fc1","roles":["support","mage"],"isWeekFree":"0","attack":"3","defense":"5","magic":"7","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/427.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/427.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u7fe0\u795e,\u827e\u7fc1,\u5c0f\u83ca,Ivern,xj,cs,aw,cuishen,aiweng,xiaoju"},{"heroId":"429","name":"\u590d\u4ec7\u4e4b\u77db","alias":"Kalista","title":"\u5361\u8389\u4e1d\u5854","roles":["marksman"],"isWeekFree":"0","attack":"8","defense":"2","magic":"4","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/429.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/429.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u590d\u4ec7\u4e4b\u77db,\u5361\u8389\u4e1d\u5854,Kalista,fczm,klst,fuchouzhimao,kalisita"},{"heroId":"432","name":"\u661f\u754c\u6e38\u795e","alias":"Bard","title":"\u5df4\u5fb7","roles":["support","mage"],"isWeekFree":"0","attack":"4","defense":"4","magic":"5","difficulty":"9","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/432.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/432.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u661f\u754c\u6e38\u795e,\u5df4\u5fb7,Bard,xingjieyoushen,bade,xjys,bd"},{"heroId":"497","name":"\u5e7b\u7fce","alias":"Rakan","title":"\u6d1b","roles":["support"],"isWeekFree":"0","attack":"2","defense":"4","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/497.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/497.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5e7b\u7fce,\u6d1b,l,hl,Rakan,huanling,luo"},{"heroId":"498","name":"\u9006\u7fbd","alias":"Xayah","title":"\u971e","roles":["marksman"],"isWeekFree":"0","attack":"10","defense":"6","magic":"1","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/498.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/498.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u9006\u7fbd,\u971e,x,ny,Xayah,niyu,xia"},{"heroId":"516","name":"\u5c71\u9690\u4e4b\u7130","alias":"Ornn","title":"\u5965\u6069","roles":["tank","fighter"],"isWeekFree":"0","attack":"5","defense":"9","magic":"3","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/516.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/516.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u5c71\u9690\u4e4b\u7130,\u5965\u6069,Ornn,an,syzy,shanyinzhiyan,aoen"},{"heroId":"517","name":"\u89e3\u8131\u8005","alias":"Sylas","title":"\u585e\u62c9\u65af","roles":["mage","assassin"],"isWeekFree":"0","attack":"3","defense":"4","magic":"8","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/517.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/517.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u89e3\u8131\u8005,\u585e\u62c9\u65af,sls,suannan,sn,jtz,Sylas,jietuozhe,sailasi"},{"heroId":"518","name":"\u4e07\u82b1\u901a\u7075","alias":"Neeko","title":"\u59ae\u853b","roles":["mage","support"],"isWeekFree":"0","attack":"1","defense":"1","magic":"9","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/518.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/518.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u4e07\u82b1\u901a\u7075,\u59ae\u853b,neeko,nk,whtl,wanhuatongling,nikou"},{"heroId":"523","name":"\u6b8b\u6708\u4e4b\u8083","alias":"Aphelios","title":"\u5384\u6590\u7409\u65af","roles":["marksman"],"isWeekFree":"0","attack":"6","defense":"2","magic":"1","difficulty":"10","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/523.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/523.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6b8b\u6708\u4e4b\u8083,\u5384\u6590\u7409\u65af,Aphelios,efls,cyzs,canyuezhisu,efeiliusi"},{"heroId":"526","name":"\u9555\u94c1\u5c11\u5973","alias":"Rell","title":"\u82ae\u5c14","roles":["tank","support"],"isWeekFree":"0","attack":"0","defense":"0","magic":"0","difficulty":"0","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/526.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/526.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"7800","couponPrice":"4500","camp":"","campId":"","keywords":"\u9555\u94c1\u5c11\u5973,\u82ae\u5c14,\u9555\u94c1,,rongtieshaonv,ruier,rongtie"},{"heroId":"555","name":"\u8840\u6e2f\u9b3c\u5f71","alias":"Pyke","title":"\u6d3e\u514b","roles":["support","assassin"],"isWeekFree":"0","attack":"9","defense":"3","magic":"1","difficulty":"7","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/555.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/555.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8840\u6e2f\u9b3c\u5f71,\u6d3e\u514b,pk,xggy,Pyke,xuegangguiying,paike"},{"heroId":"711","name":"\u6101\u4e91\u4f7f\u8005","alias":"Vex","title":"\u8587\u53e4\u4e1d","roles":["mage"],"isWeekFree":"0","attack":"0","defense":"0","magic":"0","difficulty":"0","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/711.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/711.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":""},{"heroId":"777","name":"\u5c01\u9b54\u5251\u9b42","alias":"Yone","title":"\u6c38\u6069","roles":["assassin","fighter"],"isWeekFree":"0","attack":"8","defense":"4","magic":"4","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/777.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/777.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u6c38\u6069,\u5c01\u9b54\u5251\u9b42,ye,fmjh,Yone,yongen,fengmojianhun"},{"heroId":"875","name":"\u8155\u8c6a","alias":"Sett","title":"\u745f\u63d0","roles":["fighter","tank"],"isWeekFree":"0","attack":"8","defense":"5","magic":"1","difficulty":"2","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/875.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/875.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u8155\u8c6a,\u745f\u63d0,jinfu,jf,Sett,st,wh,wanhao,seti"},{"heroId":"876","name":"\u542b\u7f9e\u84d3\u857e","alias":"Lillia","title":"\u8389\u8389\u5a05","roles":["fighter","mage"],"isWeekFree":"0","attack":"0","defense":"2","magic":"10","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/876.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/876.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u542b\u7f9e\u84d3\u857e,\u8389\u8389\u5a05,\u5c0f\u9e7f,lly,hxbl,Lillia,hanxiubeilei,liliya,xiaolu"},{"heroId":"887","name":"\u7075\u7f57\u5a03\u5a03","alias":"Gwen","title":"\u683c\u6e29","roles":["fighter","assassin"],"isWeekFree":"0","attack":"7","defense":"4","magic":"5","difficulty":"5","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/887.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/887.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"6300","couponPrice":"4500","camp":"","campId":"","keywords":"\u7075\u7f57\u5a03\u5a03,\u683c\u6e29,\u7075,\u5a03wa,gw,Gw,,lingluowawa,gewen,ling,wa"},{"heroId":"888","name":"\u70bc\u91d1\u7537\u7235","alias":"Renata","title":"\u70c8\u5a1c\u5854 \u00b7 \u6208\u62c9\u65af\u514b","roles":["support","mage"],"isWeekFree":"0","attack":"2","defense":"6","magic":"9","difficulty":"8","selectAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/choose\/888.ogg","banAudio":"https:\/\/game.gtimg.cn\/images\/lol\/act\/img\/vo\/ban\/888.ogg","isARAMweekfree":"0","ispermanentweekfree":"0","changeLabel":"\u65e0\u6539\u52a8","goldPrice":"7800","couponPrice":"4500","camp":"","campId":"","keywords":""}],"version":"12.5","fileName":"hero_list.js","fileTime":"2022-03-10 15:01:39"}
补充和总结
# 3.5补充和总结
# s="hello"
# print(Len(s)) # length 长度
# join()
# S ="python_ java_ C_ j avascript"
# lst = s.split(" ")
# print( lst )
lst = '赵本山’,'王大拿', '大张伟','马大哈']
#用_把上面的人的名字连起来
s="_".join(lst)
print(s)
#总结:
1.f"{变量}"格式化一个字符串
2.索引和切片:
索引:从0开始的. []
切片: s[start: end: step], end位置的数据永远拿不到
3.相关操作:
字符串操作对原字符串是不发生改变的.
1.upper() 在需要忽略大小写的时候
2.strip() 可以去掉字符串左右两端的空白(空格,\t, \n)
3.replace() 字符串替换
4.spLit() 对字符串进行切割
5.join() 拼接一个列表中的内容成为新字符串
6.startswith()判断字符串是否以xxx开头
7.len() 字符串长度(内置函数)
字符串的循环和遍历
for c in s:
print(c) 字符串中的每一个字符
关于in:
1. 判断xxx是否在xxxx中出现了
2. for循环
查找和判断
#查找
s = "你好啊。我时周酒发”
ret = s. find("周润发12312") #返回如果是-1就是没有该字符串出现
print(ret)
ret = s. index("周润发12312") #如果报错就是没有
print(ret)
print ("周润发123123" in s) # in可以做条件上的判断
print("周润发" not in s) # n in判断是否不存在
#判断
name = input ("请输入你的名字:") #判断你是不是姓张
if name. startswith("张"): # 判断字符串是否以xxxx开头,endswith()
print ("你姓张”)
else:
print ("不姓张")
money = input ("请输入你都里的钱:")
if money.isdigit() : # 判断字符串是否由整数组成
money = int(money)
print("可以花钱了")
else:
print("对不起,您输入有误....")
代码
# a = 10
# a += 10
# print(a)
# # 重修python基础..
# name = "周杰伦"
# print(name) # ???
# print("name") # 为什么不是周杰伦
# a = 10
# b = "a" + 1 # "a" 和 a 不是一个东西...
# print(b)
# 条件判断..
"""
if 你需要的:
存起来
else:
continue
"""
# 有的数据是我需要的. 有的是我不需要的. 我该怎么办?
# 大胆一点. 当你需要判断的时候. 首选if...
# data = {} # 数据里面有东西就是True, 没东西就是False
# if data:
# 存起来
# else:
# 拜拜
# 基础数据类型中. 所有描述为空的都是False, 其他的都是True
# 0, "", [], {}, set(), tuple(), None, False
# # 模拟爬虫
# 提取器1 = "可以提取数据"
# 提取器2 = "可以提取数据"
#
# data = 提取器1.获取数据()
#
# if data:
# 存起来
# else:
# data = 提取器2.获取数据()
# 存起来
# while True:
# 数据 = 爬取数据()
# if 数据:
# break
# time.sleep(1)
#
# while True:
# 数据 = 爬取数据()
# if not 数据:
# time.sleep(1)
# continue
# 存储数据....
# break
# print(bool(0))
# print(bool(""))
# print(bool([]))
# print(bool({}))
# print(bool(set()))
# print(bool(tuple()))
# print(bool(None))
# s = 'abc'
# s = "abc"
# s = '''abc'''
# s = """abc"""
# 帮我打印 周杰伦说: "我爱昆凌"
# \" => "
# \\ => \
# print("周杰伦说: \"我爱昆凌\"")
# print('周杰伦说: "我爱昆凌"')
# # 格式化
# name = "周杰伦"
# wife = "昆凌"
#
# s = "%s的老婆是%s" % (name, wife)
# s2 = "{}的老婆是{}".format(name, wife)
# s3 = f"{name}的老婆是{wife + name}" # f-string 推荐这个.
# print(s)
# print(s2)
# print(s3)
# # 索引和切片
# # 索引从0开始, 反着取从-1开始
# # 索引0 1 2 3 4 5 6 7 8 9
# s = "明天我上午不上班嘿嘿嘿"
# print(s[5])
# print(s[-4])
# 切片的规则, 从xxx到xxxx. 后面的这个位置取不到.
# print(s[3: 5])
# print(s[::-1]) # 把字符串翻转过来.
# 重要....
# print(s[2:]) # 前两个我不需要..
# strip, split, replace, join, startswith
# # strip(), 可以去掉字符串左右两端的空白(空格, 换行符\n, 回车符\r, 制表符\t)
# s = " \n\r\t 阿萨德加大加肥SaaS看两架飞机啊 发 "
# s = s.strip() # 字符串是不可变的数据类型. 你所有的操作都是返回给你一个新的字符串.
# print(s)
# # s.stript() # 拉出去枪毙5分钟....
# split() 对字符串进行切割. 默认是用(空白切割) 切割出来的东西会放入列表中...
# s = "001 2022 李茂换太子 128000"
# print(s.split()) # 默认用空白切割
# s = "alex_sb_樵夫_sb_沛齐"
# print(s.split("_sb_")) # 可以指定某个东西切割...
# replace() 用来做字符串替换的
# s = "alex_sb_樵夫_sb_沛齐_sb_lucky"
# print(s.replace("_sb_", "")) # 进行字符串替换
# # 干掉所有空白.或者你不需要的东西
# s = "\n\r 周 \t 杰 伦\n\r喜欢\t 我"
# print(s)
# s1 = s.replace("\n", "")
# s2 = s1.replace("\t", "")
# s3 = s2.replace("\r", "")
# s4 = s3.replace(" ", "")
# print(s4)
# lst = ["我爱", "昆凌", ", 她很好看", "但是, 她嫁人了. "]
# # 拼接
# s = "".join(lst)
# print(s)
# # startswith() 判断字符串是否以xxxx开头
# s = "张无忌"
# if s.startswith("张"):
# xxxx
# mac = "123456789010"
# address = ":".join([mac[i:i+2]for i in range(0, len(mac), 2)])
# print(address)
# lst = [] # lst = list()
# # 列表不同于字符串. 它是在原有的基础上进行操作的.
# # 增加数据(强制要求你会)
# lst.append("周杰伦")
# lst.append("昆凌")
# lst.append("王新玲")
#
# print(lst)
#
# lst.insert(2, "樵夫")
# print(lst)
# lst1 = ["张无忌", "张翠山"]
# lst2 = ["张三丰", "张三"]
# lst1.extend(lst2) # 合并两个列表
# print(lst1)
# lst = ['张无忌', '张翠山', '张三丰', '张三']
# lst[1] = "樵夫" # 用索引重新指定数据即可
# # 删除数据
# lst = ['张无忌', "李嘉诚", "李嘉欣", '张翠山', '张三丰', '张三']
# # lst.pop(1) # 用索引删除
# # print(lst)
#
# # lst.remove("张翠山") # 指定你要删除的元素
# # print(lst)
#
# for item in lst[:]: # 循环列表的同时, 想要删除列表中的内容. 用切片整体切下来
# if item.startswith("张"):
# lst.remove(item)
# print(lst)
# # range() 用来数数的.
# for i in range(10): # 0-9
# print(i)
# for i in range(10, 20): # 10-19
# print(i)
# for i in range(1, 10, 3): # 1 4 7
# print(i)
# for i in range(1, 11):
# # 更换页码
# url = f"http://www.baidu.com/page={i}" # 自动帮你str(i)
# print("爬取一页的数据", url)
# # 把lst中每一项数据增加10
# lst = [11, 22, 33, 44, 55]
# for i in range(len(lst)): # 可以循环出列表的索引
# # print(item + 10)
# item = lst[i] # 通过索引获取数据
# lst[i] = item + 10 # 修改需要索引.
# print(lst)
# # enumerate()
# lst = [11, 22, 33, 44, 55]
# for i, item in enumerate(lst):
# lst[i] = item + 10
# print(lst)
# # tuple -> 元组, 特点是不可变.
# t = (1, 2, 3, 4, 5)
# t1 = (1, ) # 如果元组只有一项数据...末尾必须有,
#
# print(t1)
# 自动解构 unpack
# a = 1, 2
# print(a)
# print(type(a))
# a, b = (1, 2) # 解包
# print(a)
# print(b)
# lst = [11, 22, 33, 44]
# # 这里隐含着unpack的过程
# for index, item in enumerate(lst):
# print(index, item)
# # 解包的时候必须保证, 变量的个数和数据的个数相同
# a, b, c, d = 1, 2, 3
# print(a, b)
# # set集合 -> 不重复
# s = set()
# s.add("周杰伦")
# s.add("昆凌")
# s.add("王力宏")
# s.add("周杰伦")
# print(s)
# lst = [11, 22, 33, 44, 11, 22, 33]
# result = set(lst)
# print(result)
s = set() # 所有不重复的名字
while 1:
# 请输入所有人的名字, 重复的不进行添加
name = input("请输入你的名字:")
s_len = len(s) # 计算长度
s.add(name) # 执行增加
new_len = len(s) # 计算新长度
if s_len == new_len:
print("重复的")
else:
print("不重复的")
# dic = {} # dic = dict()
# # 注意, 字典的key是不能重复的.
# # 在处理字典中的数据的时候. 需要用到key
# dic = {"name": "樵夫", "age": 18, "name": "哈哈哈哈"}
# print(dic)
# # 后存入的key会将之前存储的key的值替换掉..
# 增, 删(不用知道), 改, 查
# dic = {"name": "lucky"}
# # 新增数据
# # dic[key] = value
# # dic['name'] = "樵夫"
# # print(dic)
#
# # 如果key已经存在了. 那么就不执行新增的过程了
# dic.setdefault("name", "樵夫1111111")
# print(dic)
# # 删除
# dic = {"name": "樵夫", "name2": "lucky"}
# # 根据key删除
# dic.pop("name2")
# print(dic)
# dic = {"name": "lucky"}
# # dic[老key] = 新值
# dic['name'] = "樵夫6666"
# print(dic)
#
# # dic[key] = value # 保存...
#
# # 查询
# dic = {"name": "樵夫"}
# print(dic['name']) # 在字典中获取数据. 必须通过key
# print(dic.get("name")) # 通过get()也可以获取到value
# # 区别:
# # 当key不存在的时候. get() 会返回一个None, dict[key]直接报错
# # 我们在大多数情况下是知道key的值的.
# dic = {"name": "樵夫", "age": 18, "hobby": "篮球"}
# # 循环字典的操作不是很常见(切忌, 不要见到字典就循环, 列表是循环最多的)
# for k in dic: # 直接循环, 可以获取到key
# print(k, dic[k])
# # 可不可以循环添加字典内容
# lst1 = ["赵本山", "范伟", "王一博"]
# lst2 = ["马大帅", "彪哥", "我不知道"]
#
# # # 需要的数据结果: {"赵本山": "马大帅"}
# # # 1. 笨方法
# # dic = {}
# # for i in range(len(lst1)):
# # b1 = lst1[i]
# # b2 = lst2[i]
# # dic[b1] = b2
# # print(dic)
# # 2. 高级一点的方法
# # dic = {}
# # for k, v in zip(lst1, lst2):
# # dic[k] = v
# # print(dic)
#
# # # 3. 最高级版本
# # result = dict(zip(lst1, lst2))
# # print(result)
#
# # 需要的数据结果: [{"actor": "赵本山", "zuo": "马大帅"}, {"actor": "范伟"...}, {}]
# result = []
# for i in range(len(lst1)):
# dic = {}
# b1 = lst1[i]
# b2 = lst2[i]
# dic['actor'] = b1
# dic['zuo'] = b2
# result.append(dic)
# print(result)
#
# # 一条语句....不推荐....
# print([{"actory": k, "zuo": v} for k, v in zip(lst1, lst2)])
# 嵌套...
person = {
"name": "汪峰",
"age": 55,
"songs": ["春天里", "北京北京", "挪威的苦咖啡"],
"wife": {
"name": "子怡",
"age": 48,
"hobby": ["化化妆", "做做头", "跳跳舞"],
"前夫哥": {
"name": "lucky",
"age": 23,
"height": 193, # 从网页上拿到的数据. 可能有, 可能没有
"hobby": ["摩托车", "上班"]
}
},
"children": [
{"name": "alex1", "age": 41},
{"name": "alex2", "age": 42},
{"name": "alex3", "age": 43},
{"name": "alex4", "age": 44},
{"name": "alex5", "age": 45},
]
}
# # 上述字典就是一个字典的嵌套. 如何从嵌套的内容中获取到你需要的那个..
# # 剥洋葱: 一层一层的获取...
# print(person['age'])
# # 汪峰老婆的年龄
# print(person['wife']['age'])
# # 拿到前夫哥的年龄
# print(person['wife']['前夫哥']['age'])
# # 获取汪峰老婆的爱好
# print(person['wife']['hobby'])
# # 我想来一波汪峰老婆的每一个爱好.
# for item in person['wife']['hobby']:
# print(item)
# # 打印汪峰每个孩子的名字和年龄(必会的)
# for item in person['children']:
# print(item['name'], item['age'])
#
#
# r = person.get("wife")["前夫哥"].get("height")
# if r:
# pass
# # {code: 0, msg: success, data:[{}, {}]}
# # {code: 9999, msg: error, data:None} 错了
# # 被服务器反爬..
# # 有可能会返回给你各种五花八门的状况. html, {code: 9999, msg: error, data:None}
#
dic = {
"current": 2,
"limit": 20,
"count": 408995,
"list": [{"id":1381849,"prodName":"绿豆芽","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.95","highPrice":"1.0","avgPrice":"0.98","place":"","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381848,"prodName":"黄豆芽","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.85","highPrice":"0.9","avgPrice":"0.88","place":"","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381847,"prodName":"番茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"1.0","highPrice":"1.4","avgPrice":"1.2","place":"蒙冀鲁川","specInfo":"黑框","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381846,"prodName":"番茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"1.2","highPrice":"1.8","avgPrice":"1.5","place":"冀蒙","specInfo":"纸箱\\泡沫箱","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381845,"prodName":"番茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"2.0","highPrice":"2.5","avgPrice":"2.25","place":"鲁","specInfo":"白框","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381844,"prodName":"黄瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"2.7","highPrice":"3.0","avgPrice":"2.85","place":"鲁辽云","specInfo":"袋\\箱","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381843,"prodName":"黄瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"3.5","highPrice":"4.0","avgPrice":"3.75","place":"冀","specInfo":"鲜干花","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381842,"prodName":"小黄瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"4.5","highPrice":"5.5","avgPrice":"5.0","place":"辽鲁","specInfo":"旱\\荷兰","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381841,"prodName":"茄子","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.6","highPrice":"2.7","avgPrice":"1.65","place":"冀鲁蒙云","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381840,"prodName":"长茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"1.0","highPrice":"2.0","avgPrice":"1.5","place":"冀辽","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381839,"prodName":"线茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"1.5","highPrice":"5.5","avgPrice":"3.5","place":"冀京闽","specInfo":"袋\\箱","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381838,"prodName":"广茄","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"2.5","highPrice":"3.5","avgPrice":"3.0","place":"云京","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381837,"prodName":"冬瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.6","highPrice":"0.8","avgPrice":"0.7","place":"豫桂","specInfo":"吊","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381836,"prodName":"冬瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.3","highPrice":"0.4","avgPrice":"0.35","place":"苏","specInfo":"地","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381835,"prodName":"毛冬瓜","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"0.7","highPrice":"0.8","avgPrice":"0.75","place":"豫","specInfo":"长\\小","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381834,"prodName":"架豆","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"6.0","highPrice":"9.5","avgPrice":"7.75","place":"冀云闽","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381833,"prodName":"豆王","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"5.0","highPrice":"6.5","avgPrice":"5.75","place":"辽云闽","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381832,"prodName":"扁豆","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"5.0","highPrice":"6.8","avgPrice":"5.9","place":"冀鲁","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381831,"prodName":"豇豆","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"3.5","highPrice":"6.0","avgPrice":"4.75","place":"云闽桂海","specInfo":"湿\\干","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None},{"id":1381830,"prodName":"白不老","prodCatid":1186,"prodCat":"蔬菜","prodPcatid":None,"prodPcat":"","lowPrice":"4.8","highPrice":"6.8","avgPrice":"5.8","place":"辽鲁闽","specInfo":"","unitInfo":"斤","pubDate":"2022-12-30 00:00:00","status":None,"userIdCreate":138,"userIdModified":None,"userCreate":"admin","userModified":None,"gmtCreate":None,"gmtModified":None}]}
#
# for item in dic['list']: # item 拿到的就是列表中的每一个小字典.
# print(item['prodName'], item['highPrice'])
# 数据想要进行传输或者存储
#
# 在内存中使用的是unicode编码
# gbk 中国人的编码 一个中国汉字 -> 2个字节
# utf-8 可变长度的unicode, 一个中国汉字 -> 3个字节
# gbk和utf-8 是不能直接转换的.
# 从网页里拿到的字节如果是gbk, 那么你需要用gbk来处理
# 从网页里拿到的字节如果是utf-8, 那么你需要用utf-8来处理
# # \x两位 1个字节
# s = "我叫樵夫"
# # 转化成gbk看看
# bs = s.encode("gbk")
# print(bs) # b'\xce\xd2\xbd\xd0\xe9\xd4\xb7\xf2'
#
# bs2 = s.encode("utf-8")
# print(bs2) # b'\xe6\x88\x91\xe5\x8f\xab\xe6\xa8\xb5\xe5\xa4\xab'
# # 如何将字节转化回. 字符串
# bs = b'\xe6\x88\x91\xe5\x8f\xab\xe6\xa8\xb5\xe5\xa4\xab'
# s = bs.decode("utf-8")
# print(s)
# 以后需要编码的时候. 可以尝试用utf-8 如果utf-8可以. 就用utf-8
# 如果不行. 就换gbk
# 穷举法. 瞎蒙....
# 在网页端. 你能看到它用什么编码的. -> 98% 以上的网页...
# 如果网页上写的utf-8 不可用. 换gbk尝试.
# 如果都不行....极端....
# 按照网页上的编码来进行以下操作. charset="utf-8"
# 正常的用utf-8处理完.
# # 在打印的时候报错
# s = "xxxxxx" # 网页的东西.
# # 干掉所有不符合console编码的字符
# s = s.encode("gbk", "ignore").decode("gbk", "ignore")
# print(s)
# encode() 编码 -> 把字符串转化成字节
# decode() 解码 -> 把字节转化成字符串
# unicode -> 内存的编码
# gbk -> 中国人的编码
# utf-8 -> 全世界的编码
# 所有的文件读写离不开open
# open(路径, mode="模式", encoding="utf-8")
# mode:
# 1. r, read只读. 只能读. 不能写
# 2. w, write只写. 值能写, 不能读.
# 3. a, 追加写. 在文件末尾写入内容
# 4. 带b的, 处理非文本文件
# encoding: 编码
# 读取文件的时候. 文件中的内容是被编码的
# 你希望得到的是, 已经解码之后的东西了.
# 此时编码.open会自动根据你给的这个编码进行解码
# 写入文件的时候. 程序里有的是字符串.
# 写入文件之前,肯定是希望帮你进行编码操作的
# 此时编码.open会自动的帮你编码操作.#
# 给了encoding. 处理的就是字符串.
# # 读文件
# f = open("葫芦娃.txt", mode="r", encoding="utf-8")
# # s = f.read() # 全读.
#
# # 读文件的最好的方案
# for line in f:
# # print在每一行打印之后. 都会帮你增加一个换行 -> 不要管它
# # 在文件中每一行的末尾, 有一个换行符
# line = line.strip() # 最好的方案
# print(line) # 没用
# # 写文件
# # w模式.如果文件存在. 清空. 如果文件不存在. 创建
# f = open("樵夫哈哈哈.txt", mode="w", encoding="utf-8")
# f.write("你好\n")
# f.write("我好")
# f.write("\n")
# f.write("大家好")
# 带b的, 读写的是字节. 处理非文本文件. 图片, 音频, 视频.
# 从网页上下载了一张图片
# bs = b''
# f = open("樵夫.png", mode="wb")
# f.write(bs)
# # 复制一个文件
# f1 = open("abc.jpg", mode="rb")
# f2 = open("d:/hehe.jpg", mode="wb")
# f2.write(f1.read())
#
# # 总忘记关闭
# f1.close()
# f2.close()
# 下面一行代码和当前行代码是一行.
# with open("abc.jpg", mode="rb") as f1,\
# open("haha.jpg", mode="wb") as f2:
# bs = f1.read()
# f2.write(bs)
# # 坑, 深坑, 大坑. 巨坑
# lst = ['樵夫', "lucky", "沛齐", "alex", "sb"]
# # with open("老师.txt", mode="w", encoding="utf-8") as f: # 打开文件
# # for item in lst: # 循环每一个
# # f.write(item) # 写入内容
#
# # 创建 樵夫.txt,lucky.txt, 沛齐.txt
# for item in lst:
# with open(f"{item}.txt", mode="w", encoding="utf-8") as f:
# pass
# def gan():
# print("1. 挽起袖子")
# print("2. 怒发冲冠")
# print("3. 找菜刀")
# print("4. 兄弟们上")
# print("5. 回家睡觉")
#
# gan()
# print("吃饭")
#
# gan()
# print("按摩")
#
# gan()
# print("唱歌")
# # 发请求
def send(url, page, pin):
for i in range(page):
print(f"发送请求到{url}")
print(f"获取到{pin}类的数据")
# return 如果被执行了. 就结束....
return "数据" # 返回结果, 缩进的逻辑. 得你来控制.
# # 需要海产品
# data = send("http://www.haichanpin.com", 5, "海带")
# # 肉类
# send("http://www.roulei.com", 3, "排骨")
# while 1:
# print("我爱你")
# print("鬼才爱你")
# 导入模块
# import : 导入
# import haha # haha 模块
# from haha import func as 樵夫的func, func2
# from hehe import func as lucky的func
#
# 樵夫的func()
# lucky的func()
#
# from a.haha import func as f1
# from b.haha import func as f2
#
# f1()
# f2()
# import requests
# from requests import get
#
# requests.get()
# get()
# 单独开辟一个内存, 在该内存中运行haha.py文件
import haha
if __name__ == '__main__': # 多线程和多进程那里会有点儿小问题..
pass
# random -> 随机
import random
# import uuid
# print(random.randint(1, 5))
# print(random.uniform(1, 3)) # 随机小数
# print(str(uuid.uuid4()).replace("-", "")) # 永久不重复.
import time
# 1672415546600.8754 # 秒
# 1672415582725 # 毫秒
# 1672415626786
# print(time.time()) # 时间戳, 用数字来描述一个时间点
# print(int(time.time() * 1000)) # 模拟前端浏览器
# print("哈哈哈")
# time.sleep(1) # 睡眠. 让程序暂停1秒钟
# print("呵呵呵呵")
# while 1:
# print("我爱你")
# time.sleep(1) # 降低爬取频率
# os模块 -> 和你操作系统相关
import os
# r = os.path.join("a", "b", "c") # 路径拼接
# print(r) # a\b\c \ window默认的文件路径分隔符
#
# # 推荐大家使用路径的时候. 都用/ 没有转义字符的烦恼
# # "a/n/t"
# # 判断文件是否存在
# r = os.path.exists("a/haha.py")
# print(r)
# 创建文件夹 -> 一次性创建多级目录
# os.makedirs("樵夫/lucky/沛齐")
# # 总结. 正确创建文件夹的逻辑:
# path = "xxx/xxx"
# if not os.path.exists(path): # 先判断
# os.makedirs(path) # 再创建
# # open() 只能帮你造文件. 不能造文件夹
# open("xxx/xxx/xxxx.txt", mode="w")
# os还可以帮你执行命令行程序
# os.system("dir") # 无法正确显示中文. 正确的运行了该命令
# r = os.popen("dir") # 运行该命令
# print(r.read()) # 打印出运行结果
# s = '{"name": "alex", "hobby": ["妹子", "妹子", "妹子"]}'
# # 未来从网站服务器上获取到的东西就是字符串
# """ html -> 下节课lucky
# <!DOCTYPE html>
# <html lang="en">
# <head>
# <meta charset="UTF-8">
# <title>Title</title>
# </head>
# <body>
# 樵夫....
# </body>
# </html>
# """
# # 第二种格式: -> json -> dict
# # '{"name": "alex", "hobby": ["妹子", "妹子", "妹子"]}'
# # '["妹子", "妹子", "妹子"]'
#
# # python中有一个叫json的模块. 可以帮你完成 str -> dict
# #
# import json
# # str -> dict/list
# dic = json.loads(s)
# print(dic)
# print(type(dic))
#
# print(dic['hobby'][2])
# import json
#
# s = '[11,22,33]'
# lst = json.loads(s)
# print(lst)
# for item in lst:
# print(item)
# dic = {
# "examPointType": True,
# "practiceType": False,
# "questionType": None,
# "sign":"jz1",
# "subsign":"8cc80ffb9a4a5c114953",
# "top":"100",
# }
# import json
# # 需要想办法把python的字典转化成json字符串
# s = json.dumps(dic)
# print(s)
# print(type(s))
# 总结:
# json.loads() 把字符串转化成字典
# json.dumps() 把字典转化成字符串
import json
# # 坑: 在javascript中的json是没有空格的.
# dic = {"name":"alex", "age":18}
# print(json.dumps(dic, separators=(",", ":"))) # 解决处理出来的字符串中多余的空格问题
# # 乱码的问题
# dic = {"name":"樵夫", "age":18}
# print(json.dumps(dic))
#
# # {"name": "\u6a35\u592b", "age": 18}
s = '{"name": "\u6a35\u592b", "age": 18}'
print(json.loads(s))
# 异常是程序运行过程中出现的错误(不是你写代码写错了)
# 下面这个不叫异常. 叫瞎写..
# SyntaxError: invalid syntax
# # 爬虫领域: 访问次数过多. 服务器压力过大.网络连接失败. 程序产生了错误
# print(1/0) # 如果程序出错了. 没人管. 程序会中断
# # 不希望程序中断. 希望程序在出现错误之后. 可以自我反省. 继续运行
# print("我爱你")
""""
python处理异常的语法:
try:
生活当中干活. 犯事儿...
except Exception as e:
所有错误
继续....
"""
# try:
# lst = []
# print(lst[999])
# except Exception as e:
# print("出错了")
#
# # 程序可以继续运行
# print("我爱你")
# import time
# f = open("log.txt", mode="w", encoding="utf-8")
# flag = False
# # 某一页错了
# for i in range(10):
# try:
# print("发送请求, 获取服务器返回的东西")
# flag = True
# break # 什么时候成功了. 什么时候结束
# # return
# except Exception as e:
# print("出错了", e)
# time.sleep(1)
#
# if not flag:
# # url 记录在日志中... logging模块,
# f.write("xxxxurl 访问10次失败\n")
# pass
# import traceback
# try:
# print(1/0)
# except Exception as e:
# print(traceback.format_exc()) # 可以看到完整错误信息, 程序不中断.
#
# print("我爱你")
#
# def func():
# print("你好")
#
# def func2():
# print("你太好了")
#
# def func3():
# print("吼吼吼")
def func():
pass
# 这段代码是我的测试代码. 并不是给其他人用的.
# __name__ 如果是被右键-> run 运行.
# 它的值是: __main__
# 如果该文件作为模块被导入. __name__ => 模块名
if __name__ == '__main__':
# 当前py文件作为项目的启动文件时. 它里面的代码才会被运行
# 程序的入口
print("我叫赛利亚. ")