Difference between revisions of "Os (Python library)"

From wikieduonline
Jump to navigation Jump to search
 
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{lowercase}}
 
* https://docs.python.org/3/library/os.html
 
* https://docs.python.org/3/library/os.html
  
  
[[Python]]:
+
===Usage===
* <code>[[import]] os</code>
+
<code>[[import]] os</code>
  
 +
===Command execution===
 +
<code>[[os.system]]("your_code ")</code>
  
Command execution:
+
<code>[[os.system]]("[[uptime]]")</code>
os.system(" your_code ")
 
  
[[File]] management:
+
===[[File]] management===
os.close([[fd]])
+
<code>[[os.close]]([[fd]])</code>
 +
 
 +
=== Other ===
 +
<code>[[os.path]].dirname</code>
 +
<code>[[os.path]].basename</code>
 +
<code>os.path.realpath</code>
 +
[[os.path.isfile]]
 +
 
 +
[[os.environ]]['HOME']
 +
 
 +
[[os.getenv]] https://docs.python.org/3/library/os.html#os.getenv
  
 
== Example ==
 
== Example ==
<pre>
 
#!/usr/bin/env python
 
import os
 
  
os.system("echo 'Hello World'")
+
#![[/usr/bin/env]] [[python3]]
</pre>
+
import os
 +
 +
[[os.system]]("echo 'Hello World'")
 +
 
 +
== Related ==
 +
* <code>[[import subprocess]]</code>
 +
** [[subprocess.run]]
 +
* <code>[[execve]]</code>
 +
* <code>[[from os import environ]]</code>
 +
* <code>[[pathlib]]</code>
 +
* [[import psutil]]
  
 
== See also ==
 
== See also ==
 +
* {{os}}
 +
* {{import}}
 
* {{Python}}
 
* {{Python}}
  
 
[[Category:Python]]
 
[[Category:Python]]

Latest revision as of 10:33, 8 November 2024

Advertising: