我在“WHERE”方面遇到问题。我已经在命令提示符中写下了它,它工作得很好,但是使用 Popen 会生成 stderr 错误“无效动词。”。
from subprocess import Popen, PIPE
stdout, stderr = Popen([
'wmic',
'path',
'win32_videocontroller',
'WHERE "Name = \'Intel(R) UHD Graphics 630\'"',
'GET',
'Availability'
],
stdout = PIPE,
stderr = PIPE,
text = True
).communicate()
from subprocess import Popen, PIPE
stdout, stderr = Popen([
'wmic',
'path',
'Win32_VideoController',
'WHERE',
'Name=\'Intel(R) UHD Graphics 630\'',
'GET',
'/VALUE'
],
stdout = PIPE,
stderr = PIPE,
text = True
).communicate()
if len(stderr):
print(f'Error: "{stderr}"')
else:
stdout = '\r\n'.join([line.rstrip(' ') for line in stdout.split('\n\n')[1:] if len(line) and not line.endswith('=')])
stdout += '\r\n'