Directly output system commands to the screen. The command return value obtained by this method cannot be assigned to a variable. The output result will be garbled due to encoding:
<span style="color: #0000ff">import</span><span style="color: #000000"> os os.system(</span><span style="color: #800000">"</span><span style="color: #800000">ipconfig</span><span style="color: #800000">"</span>)
Store the system commands obtained by execution into the memory, and then read the results in the memory and output them to the screen without garbled characters:
<span style="color: #0000ff">import</span><span style="color: #000000"> os com </span>= os.popen(<span style="color: #800000">"</span><span style="color: #800000">ipconfig</span><span style="color: #800000">"</span><span style="color: #000000">).read() </span><span style="color: #0000ff">print</span>(com)
Create a folder in the directory where the executable file is located
<span style="color: #0000ff">import</span><span style="color: #000000"> os os.makedirs(</span><span style="color: #800000">"</span><span style="color: #800000">makedir</span><span style="color: #800000">"</span>)
The above is the detailed content of Python study notes - os module. For more information, please follow other related articles on the PHP Chinese website!