随笔分类 -  python

摘要:class People(): peoCount = 0 # 类属性 def __init__(self,name,age): # 实例属性 self.__name = name self.__age = age People.peoCount += 1 def getProperty(self): 阅读全文
posted @ 2024-03-31 15:43 远洪 阅读(14) 评论(0) 推荐(0) 编辑
摘要:一、私有变量 “_”单下划线开头的变量:_var ,表示这些函数和变量是元素私有的或内部使用的,为非强制性(实际可修改也可引用)。 "__"双下划线开头的变量:__var,表示这些函数和变量是元素私有的或内部使用的,为强制性,对象外不可修改或引用。 单下划线例子 class People(): de 阅读全文
posted @ 2024-03-30 14:42 远洪 阅读(23) 评论(0) 推荐(0) 编辑
摘要:app.run(host='127.0.0.1',port=8000,debug=True) 参考: 打开官网地址:https://flask.palletsprojects.com/en/3.0.x/quickstart/#a-minimal-application 找到以下位置: 进入页面:ht 阅读全文
posted @ 2023-11-16 13:58 远洪 阅读(28) 评论(0) 推荐(0) 编辑
摘要:import uvicorn from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} # 注意其中 main:app 中的main为你的文件名,否则会报错 阅读全文
posted @ 2023-11-16 10:23 远洪 阅读(110) 评论(0) 推荐(0) 编辑
摘要:一、废弃的第三方线程池库 :threadpool threadpool已经不建议使用了,官方文档推荐我们使用标准库中的 multiprocessing 或者 asyncio.A 来替代 官网地址:https://pypi.org/project/threadpool/ 二、python 3.2之后, 阅读全文
posted @ 2022-01-05 16:59 远洪 阅读(1316) 评论(0) 推荐(0) 编辑
摘要:# 采用默认端口(8000)建立HTTP服务 $ python -m http.server # 采用自定端口(8765)建立HTTP服务 $ python -m http.server 8765 运行效果如下: 默认会把python运行的当前目录作为 http 服务器的根目录;通过此方式可以共享一 阅读全文
posted @ 2022-01-05 15:19 远洪 阅读(339) 评论(0) 推荐(0) 编辑
摘要:接着上一篇内容继续:https://www.cnblogs.com/liyuanhong/p/15617141.html 官方文档:https://docs.python.org/zh-cn/3.7/library/asyncio-task.html # coding: utf-8 import a 阅读全文
posted @ 2021-12-12 22:07 远洪 阅读(271) 评论(0) 推荐(0) 编辑
摘要:接着上一篇文章继续:https://www.cnblogs.com/liyuanhong/p/15600908.html 可参见官方文档:https://docs.python.org/zh-cn/3.7/library/asyncio-task.html await关键字 await后面可作用于以 阅读全文
posted @ 2021-11-28 23:06 远洪 阅读(114) 评论(0) 推荐(0) 编辑
摘要:可参见python官方文档:https://docs.python.org/zh-cn/3.7/library/asyncio-eventloop.html 一、事件循环 事件循环:是python异步编程中重要的一个环节;可以理解未就是一个死循环,这个死循环会去检测并执行某些代码。 例如: # 伪代 阅读全文
posted @ 2021-11-24 23:45 远洪 阅读(1221) 评论(0) 推荐(0) 编辑
摘要:参考地址:https://www.cnblogs.com/grandlulu/p/9525417.html 一、mitemproxy是什么 顾名思义,mitmproxy 就是用于 MITM 的 proxy,MITM 即中间人攻击(Man-in-the-middle attack)。 二、mitemp 阅读全文
posted @ 2021-07-17 17:49 远洪 阅读(226) 评论(0) 推荐(0) 编辑
摘要:查看库路劲方法 import sys print(sys.path) 添加库路劲方法 sys.path.append("D:\programfiles\pythonLib") print(sys.path) 阅读全文
posted @ 2021-04-26 18:40 远洪 阅读(97) 评论(0) 推荐(0) 编辑
摘要:创建虚拟环境: python -m venv myvnev 进入虚拟环境(windows): cd myvenvcd Script activate linux: cd myvenv/bin/ source activate 退出虚拟环境: deactivate 阅读全文
posted @ 2021-04-14 15:14 远洪 阅读(1120) 评论(0) 推荐(0) 编辑
摘要:# -*- coding:utf-8 -*- from subprocess import * p = Popen('df -Th', stdout=PIPE, stderr=PIPE, shell=True ) p.wait() out = p.stdout.read() print out p 阅读全文
posted @ 2021-01-18 15:19 远洪 阅读(2021) 评论(0) 推荐(0) 编辑
摘要:wxPython使用boxSizer布局的时候,空间之间加边距,设置border的边框宽度来加边距 1 函数原型 sizer = wx.BoxSizer( integer orient ) 其中的方向(orient)可以是 wx.VERTICAL(垂直) 或 wx.HORIZONTAL(水平)。 将 阅读全文
posted @ 2020-12-31 14:35 远洪 阅读(1428) 评论(0) 推荐(0) 编辑
摘要:videoPathText = "this is test txt !" selectPathButton = wx.Button(controlView,label="选择视频文件",pos=(375,5)) self.frame.Bind(wx.EVT_BUTTON, lambda evt,te 阅读全文
posted @ 2020-12-29 18:38 远洪 阅读(429) 评论(0) 推荐(0) 编辑
摘要:请参考:https://www.cnblogs.com/liyuanhong/articles/12183279.html 使用wxpython做界面,可以使用绝对布局和Sizer 其中Sizer有分为以下几个布局管理器: 1.wx.BoxSizer 2.wx.StaticBoxSizer 3.wx 阅读全文
posted @ 2020-01-12 17:39 远洪 阅读(435) 评论(0) 推荐(0) 编辑
摘要:一、encode与decode 1、bytes主要是给在计算机看的,string主要是给人看的 2、中间有个桥梁就是编码规则,现在大趋势是utf8 3、bytes对象是二进制,很容易转换成16进制,例如\x64 4、string就是我们看到的内容,例如'abc' 5、string经过编码encode 阅读全文
posted @ 2020-01-08 17:07 远洪 阅读(2633) 评论(0) 推荐(0) 编辑
摘要:一、ASCII转换 获取字符的ascii值 获取ascii值对应的字符串 二、进制转换 十进制转16进制 十进制转8进制 十进制转二进制 16进制字符串转10进制 8进制字符串转10进制 2进制字符串转10进制 10进制字符串转10进制 阅读全文
posted @ 2020-01-08 16:04 远洪 阅读(6430) 评论(0) 推荐(0) 编辑
摘要:python int类型转换为字节如下,参考官方类库文档: int.to_bytes(length, byteorder, *, signed=False) 返回表示一个整数的字节数组。 >>> (1024).to_bytes(2, byteorder='big') b'\x04\x00' >>> 阅读全文
posted @ 2020-01-02 16:33 远洪 阅读(9380) 评论(0) 推荐(0) 编辑
摘要:wxpython从2.8升级到3.0发现2个问题 png图片出现警告 iCCP:known incorrect sRGB profile 原因是 libpng升级对iCCP的要求更严格,比较好的解决方法可以通过Imagemagick软件把png图片重新保存一下即可。 安装该工具后执行:magick 阅读全文
posted @ 2020-01-01 20:25 远洪 阅读(596) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示