![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
南下狩猎的小花猫
天生喜欢编程,就像自己喜欢地理一样,热爱到骨子里。
工作使用7年多的Java、JavaScript;
工作之外研究ANSI C、Python
展开
-
python 爬虫 小姐姐
python 爬虫 小姐姐原创 2022-08-25 16:47:29 · 3638 阅读 · 0 评论 -
excel使用openpyxl
#!/usr/bin/env python# encoding: utf-8import reimport openpyxl'''excel使用openpyxlpip install openpyxlhttps://blog.csdn.net/weixin_41546513/article/details/109555832'''# 去除HTML标签,截取20个字符def parse_html(html): pattern = re.compile(r'<[^>]+原创 2021-10-12 16:22:35 · 93 阅读 · 0 评论 -
python自学之多线程编程
runable方式启动线程:#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: threadingTest.py@time: 2018/12/20 12:08@desc:多线程编程-开启线程的两种方式-和java一样继承和runable方式'''import threadingimport time#原创 2021-06-23 12:24:02 · 130 阅读 · 1 评论 -
python自学之list、生成器
>>> mylist = [x*x for x in range(3)]>>> for i in mylist :... print(i)014>>> mygenerator = (x*x for x in range(3))>>> for i in mygenerator :... print(i)014原创 2021-06-23 12:24:14 · 270 阅读 · 0 评论 -
python自学之yield生成器
# encoding=utf8"""yield生成器"""def createGenerator(): mylist = range(3) for i in mylist: yield i * i print (u'i=%s' % i)# 执行代码if __name__ == '__main__': mygenerator = createGenerator() for i in mygenerator: pr原创 2021-06-22 09:23:33 · 64 阅读 · 0 评论 -
Python自学之while else
#! /usr/bin/env python3# -*- coding:utf-8 -*-1.# while else# 因为else语句不是独立语句而是语句块,语句块只有当回退到和与闭合的块# 一样的缩进量时语句结束,所以else语句不会单独结束'''while else意思就是while是和else一块的。当有break或者return的时候,会跳出while块,又因为while和else是一个整体,所以就跳出else,就不执行else1.所以只要没有break或者return原创 2021-06-22 09:10:22 · 446 阅读 · 0 评论 -
python自学之type()使用
#!/usr/bin/env python3# -*- coding: utf-8 -*-# @Time : 2019/4/29 17:02# @Author : 何胜金-heshengjin# @Site : # @File : type_test.py# @Software: PyCharm"""type()使用type() 函数是一个元类可以看到,在 Python 中,类也是对象,你可以动态的创建类。 其实这也就是当你使用关键字 class 时 Py原创 2021-06-22 09:06:28 · 480 阅读 · 0 评论 -
python自学之with
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: meizi.py@time: 2018/12/19 17:25@desc:testWith'''import typesimport osimport randomdef testWith(): # 不存在就创建目录 save_path原创 2021-06-22 08:53:12 · 81 阅读 · 0 评论 -
python自学之单例
#!/usr/bin/env python3# -*- coding:UTF-8 -*-"""单列模式"""class singleton(object): __instance = None name = 'none name init' age = 18 def __new__(cls, *args, **kwargs): if cls.__instance is None: cls.__instance = objec原创 2021-06-22 08:53:50 · 89 阅读 · 0 评论 -
python自学之正则表达式
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: reTest.py@time: 2018/12/20 9:27@desc:正则表达式blog-see:https://www.cnblogs.com/wxshi/p/6827056.htmlre.I(re.IGNORECASE): 忽略大小写(括号内是完整写原创 2021-06-22 08:54:12 · 99 阅读 · 0 评论 -
python自学之rang循环
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: rangTest.py@time: 2018/12/23 0023 16:16@desc:1.rang循环生成 2.多层循环'''import osif __name__ == '__main__': print( [x * x for原创 2021-06-22 08:54:32 · 195 阅读 · 0 评论 -
python自学之属性描述符使用详解
#!/usr/bin/env python3# -*- coding: utf-8 -*-# @Time : 2019/4/29 15:18# @Author : 何胜金-heshengjin# @Site : # @File : properties_desc.py# @Software: PyCharm"""属性描述符使用详解__get____set____del__"""class Meter(object): def __init__(self原创 2021-06-22 08:54:49 · 85 阅读 · 0 评论 -
python自学之变量字典
# encoding=utf8dic = {'jon': '-boy-', 'lili': '--girl--', 'numbers': 123}# 测试if __name__ == '__main__': print( dic['jon']) print( dic["jon"]) for index, key in enumerate(dic): print( u'index=%s,key=%s,value=%s' % (index, key, dic[k原创 2021-06-22 08:55:01 · 113 阅读 · 0 评论 -
python自学之魔术方法
#!/usr/bin/env python3# -*- coding: utf-8 -*-# @Time : 2019/4/29 14:52# @Author : 何胜金-heshengjin# @Site : # @File : magic_method.py# @Software: PyCharm"""魔术方法"""class MagicMethod(object): def __new__(cls, *args, **kwargs):原创 2021-06-22 08:55:16 · 109 阅读 · 0 评论 -
python自学之Iterable
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: IterableTest.py@time: 2018/12/23 0023 16:13@desc:Iterable是不是可以迭代的判断'''import collections.abcif __name__ == '__main__': prin原创 2021-06-21 17:01:53 · 120 阅读 · 0 评论 -
python自学之generator列表生成器
#!/usr/bin/env python# encoding: utf-8s = '''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: generatorTest.py@time: 2018/12/23 0023 16:28@desc:generator列表生成器-保留的仅仅是算法,使用的时候才开始'''if __name__ == '__main__': # 列表生成器原创 2021-06-21 16:52:17 · 77 阅读 · 0 评论 -
python自学之工厂模式
#!/usr/bin/env python3# -*- coding:UTF-8 -*-"""工厂模式"""#水果class Fruit(object): def __init__(self): pass def getTypeFruit(self): print('fruit')#appleclass Apple(Fruit): def __init__(self): pass def getType原创 2021-06-21 16:49:08 · 79 阅读 · 0 评论 -
python自学之枚举
#!/usr/bin/env python3# -*- coding: utf-8 -*-# @Time : 2019/4/29 16:36# @Author : 何胜金-heshengjin# @Site : # @File : enum_test.py# @Software: PyCharm"""枚举的使用"""from enum import Enum, unique# import enummonth1 = Enum("month",('January原创 2021-06-21 16:37:25 · 122 阅读 · 0 评论 -
python自学之函数参数默认值的陷阱和原理深究
#!/usr/bin/env python3# -*- coding:UTF-8 -*-"""https://blog.csdn.net/u012409883/article/details/71440711Python函数参数默认值的陷阱和原理深究,【默认参数,编译时候确定】"""# such is true ;(下面才是正确的方式)# def generate_new_list_with(my_list=None, element=None):# if my_list is No原创 2021-06-21 16:27:41 · 93 阅读 · 0 评论 -
python自学之一般装饰器装饰器、带参数的装饰器
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: decoratorTest.py@time: 2018/12/20 15:15@desc:一般装饰器装饰器、带参数的装饰器'''# ===========一般装饰器================def debug(func): def wrappe原创 2021-06-21 16:24:42 · 94 阅读 · 0 评论 -
python自学之变量作用域nonlocal、global
#!/usr/bin/env python3# -*- coding: utf-8 -*-# @Time : 2019/4/29 17:57# @Author : 何胜金-heshengjin# @Site : # @File : closure_test.py# @Software: PyCharm""" python 的变量作用域看起来和JavaScript一致 nonlocal只会在闭包函数查找 global设为全局变量"""time = 100de.原创 2021-06-21 16:11:24 · 75 阅读 · 0 评论 -
python自学之类属性、类方法和实例属性、实例方法
#!/usr/bin/env python3# -*- coding:UTF-8 -*-"""python的类属性、类方法和实例属性、实例方法类似于JavaScript方式,类属性和类方法就在prototype上面(当然python没有原型概念,挂在类上面)see:http://www.binarydance.top/aticle_view.html?aticle_id=495415157879746560&t=1624261166678<!DOCTYPE html>&原创 2021-06-21 15:48:26 · 214 阅读 · 0 评论 -
自学python之基本参数、可变参数、关键字参数
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: argumentsTest.py@time: 2018/12/22 0022 16:37@desc: python数据类型: 1、字符串 isinstance str 2、布尔类型 isinstance bool原创 2021-06-21 15:01:02 · 119 阅读 · 0 评论 -
自学python之访问属性
#!/usr/bin/env python# encoding: utf-8'''@author: heshengjin-何胜金@contact: 2356899074@qq.com@software: pycharm@file: accessTest.py@time: 2019/4/21 0021 20:32@desc:访问属性测试__xx 这是私有变量, 只有内部可以访问,外部不可以访问。但是也不是一定不可以访问,只要以 _类名__xx样式就可以访问 。但最好不要这样做,养成良好编程习原创 2021-06-21 14:00:53 · 162 阅读 · 0 评论 -
python新式类旧式类
新式类:广度优选旧式类:深度优选原创 2019-10-15 12:51:15 · 112 阅读 · 0 评论 -
python生成器/list转换
g = (range(100)) print(g) g = (r for r in g) print(g) g = list(g) print(g)输出:range(0, 100)<generator object at 0x0000000001EDC318>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,...原创 2019-10-12 16:50:15 · 1259 阅读 · 0 评论 -
python打开文件或者创建文件
def createTempDirectory(): # with as 方式打开文件IO获取文件句柄;省略try...catch...;类似java里面的try...with...resource... with tempfile.TemporaryDirectory() as directory: print('临时目录 %s' % directory)...原创 2019-10-12 14:21:04 · 651 阅读 · 0 评论 -
python文件头部
经常忘记,做一个备忘录以供复制copy粘贴paste#! usr/bin/python# -*- coding:utf-8 -*-原创 2019-10-11 17:12:48 · 990 阅读 · 0 评论 -
Python 操作 MySQL 的正确姿势
原文地址:https://www.cnblogs.com/liuliliuli2017/p/6763988.htmlPython 操作 MySQL 的正确姿势收录待用,修改转载已取得腾讯云授权作者 |邵建永编辑 | 顾乡使用Python进行MySQL的库主要有三个,Python-MySQL(更熟悉的名字可能是MySQLdb),PyMySQL和SQLAlchemy。Python-MySQ...转载 2018-12-24 11:24:34 · 174 阅读 · 0 评论