跳至主要内容

博文

实战 之 python用Win32 API 并创建 Windows服务

http://timgolden.me.uk/pywin32-docs/contents.html https://pypi.org/project/pywin32/#files 下载python版本对应的pywin32版本 pywin32-227-cp38-cp38-win32.whl(要用32位的) # 安装227版本的pywin32 # 方法一:pip install pywin32==227 # 方法二:pip install "C:\Users\DZL\Downloads\pywin32-227-cp38-cp38-win32.whl" # 删除文件时不会提示文件被占用 import os import win32file import msvcrt filename = "开票软件日志.log" # get an handle using win32 API, specifyng the SHARED access! handle = win32file . CreateFile ( filename , win32file . GENERIC_READ , win32file . FILE_SHARE_DELETE | win32file . FILE_SHARE_READ | win32file . FILE_SHARE_WRITE , None , win32file . OPEN_EXISTING , 0 , None ) # detach the handle detached_handle = handle . Detach...

python 之 xml

http://python101.pythonlibrary.org/chapter23_xml.html ElementTree 创建 import   xml . etree . ElementTree   as   xml   def  createXML ( filename ) :      """    Create an example XML file    """     root  =   xml . Element ( "zAppointments" )     appt  =   xml . Element ( "appointment" )     root. append ( appt )        # add appointment children     begin  =   xml . SubElement ( appt ,   "begin" )     begin. text   =   "1181251680"       uid  =   xml . SubElement ( appt ,   "uid" )     uid. text   =   "040000008200E000"       alarmTime  =   xml . SubElement ( appt ,   "alarmTime" )     alarmTime. text   =   "1181572063"       state  =   xml . SubElement ( appt ,   "state" )   ...