随笔分类 -  编程_Python

摘要:import ctypes from pymxs import runtime as rt user32 = ctypes.windll.user32 GA_ROOTOWNER = 3 def isMaxForeground(): fgw = user32.GetForegroundWindow() 阅读全文
posted @ 2024-07-24 14:23 ibingshan 阅读(103) 评论(0) 推荐(0)
摘要:python ValueError: Attempted relative import in non-package __package__属性标志的是模块所在的模块包名,方便我们用相对导入(例如 from . import xxx),但是当我们直接运行这个文件的时候__package__ = N 阅读全文
posted @ 2022-07-08 11:44 ibingshan 阅读(570) 评论(0) 推荐(0)
摘要:python raise 去除trackback信息 使用情况:有时候我们使用subprocess来启动另外的python程序,raise的信息会在stderr中,但是traceback的内容是raise所在行,对debug没什么帮助 可以使用 raise SystemExit('your msg' 阅读全文
posted @ 2022-03-14 16:15 ibingshan 阅读(358) 评论(0) 推荐(0)
摘要:使用 wing ide wingdbstub.py 调试代码 在wing的安装目录下,拷贝一个wingdbstub.py 修改: kEmbedded = 1 如果正常安装wing,系统会有一个环境变量'WINGHOME'记录wing的安装目录,如果是绿色版,那么最好是自己手动添加一下,如果不想添加环 阅读全文
posted @ 2022-02-17 18:16 ibingshan 阅读(163) 评论(0) 推荐(0)
摘要:python 正则表达式 按大写字母、中文、特殊符号分离字符串 import re def split_except_alphabetDigitChinese(unicode_str): """ @return:['matched str', ''] """ if type(unicode_str) 阅读全文
posted @ 2022-01-26 11:04 ibingshan 阅读(871) 评论(0) 推荐(0)
摘要:python pyside pyqt reload TypeError: super(type, obj): obj must be an instance or subtype of type 一开始遇到这个问题,在网上找了不少解决方法,这里提供链接仅供参考:https://blog.csdn.n 阅读全文
posted @ 2022-01-17 16:26 ibingshan 阅读(1193) 评论(0) 推荐(0)
摘要:Python os.walk 停止遍历满足条件的文件夹 import os for here, dirs, files in os.walk(startdir, topdown=True): dirs[:] = [] 注意:dirs[:] = [] 不能改为 dirs = [] 阅读全文
posted @ 2021-12-31 17:56 ibingshan 阅读(312) 评论(0) 推荐(0)
摘要:python 合并数组为一个总数组 import itertools ab = itertools.chain(['it'], ['was'], ['annoying']) list(ab) #if there is a list of list my_list = [['it'], ['was'] 阅读全文
posted @ 2021-06-25 16:00 ibingshan 阅读(206) 评论(0) 推荐(0)
摘要:Python 编译 pyc import py_compile sourceFile = 'd:/test.py' targetFile = 'd:/test.pyc' py_compile.compile(sourceFile, cfile = targetFile) 阅读全文
posted @ 2021-04-13 17:26 ibingshan 阅读(132) 评论(0) 推荐(0)
摘要:Python在cmd中运行一段字符串 python -c "print 'a'" 阅读全文
posted @ 2021-04-12 11:02 ibingshan 阅读(343) 评论(0) 推荐(0)
摘要:python linecache模块 读取文件行使用注意事项 在python中,使用linecache模块读取文件的行很方便 import linecache filename = 'd:/test.txt' linecache.getline(filename, 2) 但是需要注意的是,如果fil 阅读全文
posted @ 2020-05-30 11:18 ibingshan 阅读(863) 评论(0) 推荐(0)
摘要:python listdir() 中文路径 中文文件夹 乱码 解决方法 listdir(path)返回的结果的编码似乎和我们提供的 path 参数的编码有关: import os path = 'd:/test' try: path = unicode(path, 'utf-8') # 经过编码处理 阅读全文
posted @ 2019-09-10 15:44 ibingshan 阅读(6570) 评论(0) 推荐(0)
摘要:pyqt pyside qcombobox disable wheel scrolling,去除滚轮改变值和获取焦点功能 from PyQt5 import QtWidgets, QtCore class CustemComboBox(QtWidgets.QComboBox): def __init 阅读全文
posted @ 2019-09-03 17:58 ibingshan 阅读(1979) 评论(0) 推荐(1)
摘要:Python window console 控制台 实现最后一行输出 print 重写 在 python 2 ,3 中都可以 附加一个更多功能的链接:https://www.cnblogs.com/zzliu/p/10156658.html 阅读全文
posted @ 2019-07-31 17:10 ibingshan 阅读(1469) 评论(0) 推荐(0)
摘要:python cmd 窗口 中文乱码 解决方法 (附:打印不同颜色) 前言 在 python 开发中,有时候想通过cmd窗口来和用户交互,比如显示信息之类的,会比自己创建 GUI 来的方便,但是随之而来的就是编码乱码问题 下面例子在 python2 和 python3 中都可以运行,也可以在其它 . 阅读全文
posted @ 2019-07-19 16:41 ibingshan 阅读(3268) 评论(0) 推荐(0)
摘要:python 打印 str 字符串的实际内容 repr(str) s = 'aa' print(repr(s)) 阅读全文
posted @ 2019-07-15 19:16 ibingshan 阅读(644) 评论(0) 推荐(0)
摘要:python 前置程序窗口,还原最小化的窗口 在网上找了比较久,大多是: win32gui.FindWindow(class_name, window_name) win32gui.SetForegroundWindow(self._handle) 这样只会高亮那个窗口,并不会还原大小,下面是根据参 阅读全文
posted @ 2019-07-12 14:52 ibingshan 阅读(5879) 评论(1) 推荐(0)
摘要:python .pth 文件 和 site 模块 .pth 文件 该文件位于 python 的 /Lib/site-packages 目录下,可以有多个,在 .pth 文件中可以把其它目录添加到 sys.path 中,可以是相对路径和绝对路径,例如: #注释只能单独一行,以#开头 #绝对路径 d:/ 阅读全文
posted @ 2019-06-25 14:11 ibingshan 阅读(4786) 评论(0) 推荐(0)
摘要:python Pillow 图片处理模块,好强大有没有 Pillow 需要给 python 另外安装 第一个用法:https://www.cnblogs.com/ibingshan/p/11057390.html ico to png: 阅读全文
posted @ 2019-06-20 15:30 ibingshan 阅读(437) 评论(0) 推荐(0)
摘要:Python 获取 exe 的 icon(图标) 并且保存 参考链接:https://mail.python.org/pipermail/python-win32/2009-April/009078.html import win32ui import win32gui import win32co 阅读全文
posted @ 2019-06-20 10:52 ibingshan 阅读(4157) 评论(3) 推荐(2)