Python
5 subscribers
14 photos
10 videos
94 links
ف
Download Telegram
Forwarded from Python3
❗️🆕️یه کد کار بردی جدید

👇این یکی آپدیت اون کدی هست که CPU رو اسکن می‌کرد این یکی یه جدول درست میکنه و اطلاعات سخت افزاری دستگاه نشون می‌ده 👇

🟥البته که این کد روی همه سیستم عامل ها و سخت افزار ها کار می‌کنه ❗️


import psutil
import GPUtil


def get_cpu_specs():
cpu_freq = psutil.cpu_freq().current
return f"{cpu_freq / 1000:.2f} GHz"


def get_ram_specs():
ram = psutil.virtual_memory().total
return f"{ram / (1024**3):.2f} GB"


def get_gpu_specs():
gpus = GPUtil.getGPUs()
if gpus:
gpu = gpus[0]
return f"{gpu.name}, {gpu.memoryTotal} MB"
else:
return "No GPU found"


def get_ssd_specs():
disk_info = psutil.disk_usage('/')
return f"{disk_info.total / (1024**3):.2f} GB"


def draw_specs_table():
components = {
'CPU': get_cpu_specs(),
'RAM': get_ram_specs(),
'GPU': get_gpu_specs(),
'SSD': get_ssd_specs()
}

header = "| Component | Specs |"
separator = "+" + "-" * (len(header) - 2) + "+"

print(separator)
print(header)
print(separator)

for component, specs in components.items():
line = f"| {component.ljust(9)} | {specs.ljust(13)} |"
print(line)
print(separator)


draw_specs_table()


[اینم کانال منه]

❗️ری اکشن یادتون نره😉

#cpu #پایتون #کاربردی