I just asked a question, and I'm going to change the question. In the subprocess----

Asked 2 years ago, Updated 2 years ago, 65 views

How do I run the following cmd command with subprocess.check_output?

cd C:/Users/Administrator/Desktop/files
dir /b | find /i "copy"

subprocess error

2022-09-21 21:47

1 Answers

In [1]: import os

In [2]: import subprocess

In [3]: os.chdir("D:\workspacke\python\py35_x86")

In [4]: output = subprocess.check_output('dir/b | find/i "copy", shell=True)

In [5]: print(output)
b'\xbb\xe7\xba\xbb aaa.txt\r\n'

In [6]: print(output.decode('euc-kr'))
Copy aaa.txt


2022-09-21 21:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.