我已經嘗試過使用 os.system、startswith 等以及各種其他子行程函式(check_output、run、call、...),但
TypeError: argument of type 'CompletedProcess' is not iterable在第 4 行出現錯誤
這是我的代碼:
import subprocess
version = subprocess.run("wmic get os version")
if "10.0.22000" in version:
print("You are running version 10.0.22000")
else:
print("You are not running version 10.0.22000")```
uj5u.com熱心網友回復:
您需要將"wmic get os version"文本切換為"wmic os get version",然后將結果轉換為字串:
import subprocess
version = subprocess.run("wmic os get version")
if "10.0.22000" in str(version):
print("You are running version 10.0.22000")
else:
print("You are not running version 10.0.22000")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/437115.html
上一篇:如何按順序排列圖示?
