随笔分类 -  Python3学习

Python3基础的学习实录
摘要:import pynput import time import re import threading class ControlMouseKeyboard(object): mouse = pynput.mouse.Controller() keyboard = pynput.keyboard. 阅读全文
posted @ 2020-04-27 18:15 Gex 阅读(1842) 评论(2) 推荐(1)
摘要:def listener_mouse(self): self.keyoard_listener = pynput.keyboard.Listener(on_press=self.keyboard_input_press, on_release=self.keyboard_input_release) 阅读全文
posted @ 2020-04-24 16:22 Gex 阅读(1935) 评论(0) 推荐(0)
摘要:控制鼠标 from pynput.mouse import Button, Controller mouse = Controller() print('The current pointer position is {0}'.format(mouse.position)) # 设置鼠标坐标 mou 阅读全文
posted @ 2020-04-21 16:19 Gex 阅读(890) 评论(0) 推荐(1)
摘要:一、os.system() 只返回对应状态码,且状态码只会有0(成功)、1、2。 此会将结果之间输出,所有在对返回值没有分析时可用 os.system(cmd) 二、os.popen() 返回脚本命令输出的内容 os.popen()可以实现一个“管道”,从这个命令获取的值可以继续被调用。而os.sy 阅读全文
posted @ 2020-04-10 15:25 Gex 阅读(4170) 评论(0) 推荐(0)
摘要:import win32api #winapi库 import win32con #windows常数定义 win32api.MessageBox(win32con.NULL, "在过去的1分钟内,CPU连续五次超过4%", "cpu提示") 阅读全文
posted @ 2020-04-08 11:23 Gex 阅读(815) 评论(0) 推荐(0)
摘要:from serial import Serial from types import FunctionType,MethodType #与类和实例无绑定关系的function都属于函数(function); #与类和实例有绑定关系的function都属于方法(method)。 def open_s 阅读全文
posted @ 2020-04-08 11:21 Gex 阅读(400) 评论(0) 推荐(0)
摘要:class HangUp(object): current_path = os.getcwd() test_path = current_path + r'/log/' log_name = test_path + time.strftime('%Y-%m-%d %H-%M-%S') + ".log 阅读全文
posted @ 2020-04-08 11:05 Gex 阅读(147) 评论(0) 推荐(0)
摘要:str = "www.runoob.com" print(str.upper()) # 把所有字符中的小写字母转换成大写字母 print(str.lower()) # 把所有字符中的大写字母转换成小写字母 print(str.capitalize()) # 把第一个字母转化为大写字母,其余小写 pr 阅读全文
posted @ 2020-03-24 15:48 Gex 阅读(522) 评论(0) 推荐(0)
摘要:以下是 configparser 模块的基本方法: 读取配置文件 defaults() 返回包含实例范围默认值的字典 read(filename) 直接读取ini文件内容 sections() 获取所有的 section,以列表的形式返回 options(section) 获取指定 section 阅读全文
posted @ 2019-12-26 18:21 Gex 阅读(446) 评论(0) 推荐(0)
摘要:Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能。 基本语法是通过 {} 和 : 来代替以前的 % 。 format 函数可以接受不限个参数,位置可以不按顺序。 >>>"{} {}".format("hello", "world") # 不 阅读全文
posted @ 2019-12-03 17:30 Gex 阅读(193) 评论(0) 推荐(0)
摘要:random模块 random.randint(1,10)--随机生成0-10之间的随机整数 random.uniform(1,10)--随机生成0-10之间的实数 random.randrange(9,100,10)--从9-100之间随机选取一个实数,差为10,也就是说从9,19,29,39,4 阅读全文
posted @ 2019-11-25 10:07 Gex 阅读(4804) 评论(0) 推荐(1)
摘要:Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Permission denied Error while obtaining UI hierarchy XML file: com.andr 阅读全文
posted @ 2019-10-28 16:21 Gex 阅读(536) 评论(0) 推荐(0)
摘要:最近想打包自己写的程序,前面用了Python pyinstaller,但是总会出现其他目录的.py文件找不到的问题,弄了一天,放弃了。现在试试Python cx_freeze。 安装: pip install cx-freeze 安装。在安装时出现 error: Microsoft Visual C 阅读全文
posted @ 2019-07-30 15:14 Gex 阅读(19559) 评论(0) 推荐(1)
摘要:在64位机器上,且使用64位python,pip install PyAutoIt的过程中,可能会报如下错误: File "c:\program files\python37\lib\ctypes\__init__.py", line 356, in __init__ self._handle = 阅读全文
posted @ 2019-07-11 14:10 Gex 阅读(2805) 评论(0) 推荐(0)
摘要:for case in case_name: mod = importlib.import_module('tests.'+case)#动态导入tests目录下的case clas = getattr(mod, case)#实例化case atts = dir(clas)#获得case属性 for 阅读全文
posted @ 2019-05-24 16:20 Gex 阅读(1692) 评论(3) 推荐(0)
摘要:比较2个字符串,输出看起来一样,但比较起来不同 将2个字符串改为bytes 输出: b=bytes(results[i], encoding='unicode-escape') b'AT?\\nOK\\n' b'AT?\r\r\nOK\r\n' 才发现坑爹的不同 阅读全文
posted @ 2019-05-24 09:56 Gex 阅读(704) 评论(0) 推荐(0)
摘要:截图函数 PyAutoGUI可以截取屏幕截图,将其保存到文件中,并在屏幕中查找图像。如果您有一个小图像,例如需要单击并希望在屏幕上找到它的按钮,这将非常有用。这些功能由PyScreeze模块提供,该模块与PyAutoGUI一起安装。 屏幕截图功能需要Pillow模块。OS X使用操作系统screen 阅读全文
posted @ 2019-04-29 14:12 Gex 阅读(26622) 评论(0) 推荐(1)
摘要:消息框功能 PyAutoGUI利用PyMsgBox中的消息框函数提供跨平台的纯Python方式来显示JavaScript样式的消息框。提供了四个消息框功能: alert()函数 >>> pyautogui.alert(text="123456",title="iyoukrls",button="ok 阅读全文
posted @ 2019-04-29 14:02 Gex 阅读(3754) 评论(0) 推荐(0)
摘要:typewrite()函数 主要的键盘功能是typewrite()。此函数将键入字符串中传递的字符。要在按下每个字符键之间添加延迟间隔,请为interval关键字参数传递int float 。 >>> pyautogui.typewrite('Hello world!') >>> pyautogui 阅读全文
posted @ 2019-04-29 11:55 Gex 阅读(9355) 评论(0) 推荐(0)
摘要:0,0 X increases --> + + | | Y increases | | | | 1920 x 1080 screen | | | | V | | | | + + 1919, 1079 屏幕分辨率大小由size()函数返回为两个整数的元组。position()函数返回鼠标光标的当前X和 阅读全文
posted @ 2019-04-29 11:47 Gex 阅读(3649) 评论(0) 推荐(0)