2021年3月3日

python10 匿名函数

摘要: 1 阅读全文

posted @ 2021-03-03 11:05 doubleqing 阅读(29) 评论(0) 推荐(0) 编辑

2021年2月7日

python9 装饰器

摘要: ##装饰器 ''' 装饰器特点 1 函数A是作为参数出现的(函数B就接收函数A作为参数) 2 要有闭包的特点 ''' def decorator(func): a=100 print('wrapper外层打印测试') def wrapper(): func() print('刷漆') print(' 阅读全文

posted @ 2021-02-07 17:40 doubleqing 阅读(53) 评论(0) 推荐(0) 编辑

2021年2月3日

python格式化

摘要: 快捷鍵crtl+shift+f或者crtl+alt+L PEP8规则 阅读全文

posted @ 2021-02-03 14:40 doubleqing 阅读(77) 评论(0) 推荐(0) 编辑

2021年2月2日

python8 闭包

摘要: ''' 闭包条件 1 在外部函数中定义了内部函数 2 外部函数有返回值 3 返回值是内部函数,但是不能加括号,加括号表示调用 4 内部函数引用了外部函数的变量值 格式 def 外部函数() def 内部函数() return 内部函数 ''' def func(): a = 100 def inne 阅读全文

posted @ 2021-02-02 22:16 doubleqing 阅读(46) 评论(0) 推荐(0) 编辑

python7函数嵌套

摘要: def func(): n = 100 list1 = [1, 2, 3, 4] def inner_func(): global a#修改全局不可变变量 #nonlocal n#修改外部函数的不可变变量 for index, i in enumerate(list1): list1[index] 阅读全文

posted @ 2021-02-02 18:31 doubleqing 阅读(65) 评论(0) 推荐(0) 编辑

python6 可变参数和关键字参数

摘要: def aa(**kwargs): print(kwargs) aa(a=1, b='hello', c='tom') # 将关键字装包成字典 dict1 = {'a': 1, 'b': 'hello', 'c': 'tom'} aa(**dict1)#调用里面放两个**就是拆包,定义的时候放两个* 阅读全文

posted @ 2021-02-02 01:34 doubleqing 阅读(67) 评论(0) 推荐(0) 编辑

2021年1月30日

python5 元组

摘要: ###不重复特点 list1= [3,5,8,9,9]#有重复数字 #把list放到集合里面可以实现去重效果 s1 = set()#创建空集合 s2 = {}#创建空字典 s3 = set(list1)#去重 print(s3) ###参数的默认值 stu={'1':('cai',1),'2':(' 阅读全文

posted @ 2021-01-30 19:20 doubleqing 阅读(108) 评论(0) 推荐(0) 编辑

列表与字典之间的转换

摘要: ###字典相加 dict1 = {'张三':100,'李四':100,'王五':100,'赵六':10} dict2 = {'张yi':100,'李四':100,'王五':100,'赵六':10} result = dict1.update(dict2) print(result) print(di 阅读全文

posted @ 2021-01-30 12:49 doubleqing 阅读(448) 评论(0) 推荐(0) 编辑

2020年11月13日

python读取mat数据集

摘要: 以http://ufldl.stanford.edu/housenumbers/上的mat数据集为例 需要注意以下几点 从mat提取出来的数据以字典的形式保存,所以需要提取字典的key和value import numpy as np import os from PIL import Image 阅读全文

posted @ 2020-11-13 10:07 doubleqing 阅读(2936) 评论(0) 推荐(0) 编辑

2020年11月5日

add-pytorch代码实现

摘要: 运行的是GitHub关于GAN算法的最高赞代码https://github.com/corenel/pytorch-adda 这个代码直接运行是不能直接出结果的,需要进行以下修改: 大佬的安装环境是 Python 3.6 PyTorch 0.2.0 但是我在anaconda上搭建的pytorch0. 阅读全文

posted @ 2020-11-05 09:38 doubleqing 阅读(311) 评论(0) 推荐(0) 编辑

导航