0

How i can get output in variable from os module

I want take the output of os module on windows, for exemple : os.System("dir") I want take the output of "cmd > dir" and assign it to variable. For another use.??

15th Nov 2021, 2:21 AM
Mr. anrsaad
Mr. anrsaad - avatar
3 ответов
+ 1
Oh and most languages have a way to do this without using cmd or another shell. For example python has the "os" library and you can use "os.listdir" to get the contents out a directory
18th Nov 2021, 9:12 PM
C0D3 Crafter
0
Not sure what language you are using. But I can tell you that if you do "> [file]" after a cmd command you can output it to a file then you could read the file and parse the data
18th Nov 2021, 9:00 PM
C0D3 Crafter
0
Thanks to answer, i am using Python3, os module not do the job, or maybe i dont know how, so i use command tasklist and i want to get output, i know this method to write the output into file then get it, but that take so much memory, i am looking for a method to get output directly from command
18th Nov 2021, 9:52 PM
Mr. anrsaad
Mr. anrsaad - avatar