I have a command like this ".exe abcd >c:\\filename.txt" in command prompt I run then need to press two times enter button then filename.txt getting the value but I used
os.system(".exe abcd >c:\filename.txt")
then file becomes empty how to resolve this issue using python
Use the subprocess
module to create the process. Use the arguments of call
to specify the standard input, output and error streams.
Example:
with open('somefile.txt','w') as f:
subprocess.call(["command.exe", "abcd"], stdout=f)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.