永发信息网

如何用python发送windows通知

答案:2  悬赏:30  手机版
解决时间 2021-02-13 15:30
  • 提问者网友:流星是天使的眼泪
  • 2021-02-12 20:59
如何用python发送windows通知
最佳答案
  • 五星知识达人网友:底特律间谍
  • 2021-02-12 22:30
mport pythoncom

import win32serviceutil

import win32service

import win32event

import servicemanager

import socket

class AppServerSvc (win32serviceutil.ServiceFramework):

_svc_name_ = "TestService"

_svc_display_name_ = "Test Service"

def __init__(self,args):

win32serviceutil.ServiceFramework.__init__(self,args)

self.hWaitStop = win32event.CreateEvent(None,0,0,None)

socket.setdefaulttimeout(60)

def SvcStop(self):

self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):

servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,

servicemanager.PYS_SERVICE_STARTED,

(self._svc_name_,''))

self.main()

def main(self):

pass

if __name__ == '__main__':

win32serviceutil.HandleCommandLine(AppServerSvc)
全部回答
  • 1楼网友:英雄的欲望
  • 2021-02-12 23:02
在windows下换行时,有两个字符:回车(/r)和换行(/n)。但在linux下,只有一个换行(/n)可使用unix2dos和dos2unix命令进行格式的转换: 参数: -k 保持输出文件和输入文件的日期时间戳不变 -o file 默认模式 . 将file转换,并输出到file -n infile outfile 新模式. 转换infile, 并输出到outfile 1. unix2dos 假设用vi新建一文本文件,输入123456 [root@centos test]# ls -l a.txt -rw-r--r-- 1 root root 7 jan 7 21:31 a.txt [root@centos test]# hexdump -c a.txt 0000000 1 2 3 4 5 6 /n 0000007 [root@centos test]# unix2dos -n a.txt b.txt unix2dos: converting file a.txt to file b.txt in dos format ... [root@centos test]# ls -l total 8 -rw-r--r-- 1 root root 7 jan 7 21:31 a.txt -rw------- 1 root root 8 jan 7 21:34 b.txt [root@centos test]# hexdump -c a.txt 0000000 1 2 3 4 5 6 /n 0000007 [root@centos test]# hexdump -c b.txt 0000000 1 2 3 4 5 6 /r /n 0000008 b.txt是转换后的dos下的文件
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯