python的实用《jpg转png》《获取店配置信息》

# 图片格式转换, jpg转png

# 方法一

from PIL import Image

img = Image.open('test.jpg')

img.save('test1.png')

# 方法二

from cv2 import imread, imwrite

image = imread("test.jpg", 1)

imwrite("test2.png", image)


# 获取计算机信息

import wmi

def System_spec():

    Pc = wmi.WMI()

    os_info = Pc.Win32_OperatingSystem()[0]

    processor = Pc.Win32_Processor()[0]

    Gpu = Pc.Win32_VideoController()[0]

    os_name = os_info.Name.encode('utf-8').split(b'|')[0]

    ram = float(os_info.TotalVisibleMemorySize) / 1048576

    print(f'操作系统: {os_name}')

    print(f'CPU: {processor.Name}')

    print(f'内存: {ram} GB')

    print(f'显卡: {Gpu.Name}')

    print("\n计算机信息如上 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑")

System_spec()


木辛 2023-10-21