社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

使用php服务器读取python输出

Monolica • 4 年前 • 249 次点击  

我正在编写一个简单的python脚本,该脚本不断检查充电器是否连接到计算机,并在充电器从计算机上卸下时创建一个peep声音(有点防盗),如果使用nircmd命令禁用了系统音量,则启用系统音量。

我正在寻找一种将这些信息发送到PHP服务器并从那里在线阅读的方法。有谁能告诉我如何将输出从客户端发送到服务器端吗?提前非常感谢,这是密码

import os
import ctypes
import time
from ctypes import wintypes
import winsound
import socket
class SYSTEM_POWER_STATUS(ctypes.Structure):
    _fields_ = [
        ('ACLineStatus', wintypes.BYTE),
        ('BatteryFlag', wintypes.BYTE),
        ('BatteryLifePercent', wintypes.BYTE),
        ('BatteryLifeTime', wintypes.DWORD),
        ('BatteryFullLifeTime', wintypes.DWORD),
    ]
print(socket.gethostname())

SYSTEM_POWER_STATUS_P = ctypes.POINTER(SYSTEM_POWER_STATUS)

GetSystemPowerStatus = ctypes.windll.kernel32.GetSystemPowerStatus
GetSystemPowerStatus.argtypes = [SYSTEM_POWER_STATUS_P]
GetSystemPowerStatus.restype = wintypes.BOOL
status = SYSTEM_POWER_STATUS()
while True: 
        if not GetSystemPowerStatus(ctypes.pointer(status)):
            raise ctypes.WinError()
        if(status.ACLineStatus==1):
            print('Charger Connected: ', "YES")
        elif(status.ACLineStatus==0):
            print('Charger Connected: ', "NO")
            winsound.Beep(2000,1000)
        if(status.BatteryFlag==-128):
            print('Battery removed: ', "Yes")
            winsound.Beep(2000,1000)
        time.sleep(1)
        if(status.ACLineStatus==0):
                cmd = 'nircmd.exe mutesysvolume 0 && nircmd.exe setsysvolume 65535'
                os.system(cmd)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50966
 
249 次点击  
文章 [ 2 ]  |  最新文章 4 年前