Difference between revisions of "Os (Python library)"
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 | ||
− | + | ===Usage=== | |
− | + | <code>[[import]] os</code> | |
+ | ===Command execution=== | ||
+ | <code>[[os.system]]("your_code ")</code> | ||
− | + | <code>[[os.system]]("[[uptime]]")</code> | |
− | |||
− | [[File]] management | + | ===[[File]] management=== |
− | + | <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 == | ||
− | |||
− | |||
− | |||
− | os.system("echo 'Hello World'") | + | #![[/usr/bin/env]] [[python3]] |
− | </ | + | 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
Usage[edit]
import os
Command execution[edit]
os.system("your_code ")
File management[edit]
Other[edit]
os.path.dirname
os.path.basename
os.path.realpath
os.path.isfile
os.environ['HOME']
os.getenv https://docs.python.org/3/library/os.html#os.getenv
Example[edit]
#!/usr/bin/env python3 import os os.system("echo 'Hello World'")
Related[edit]
See also[edit]
- import os, os.path
- import, import (Python):
import [ os | argparse | sys | psutil | yaml | logging | websockets ]
,from
- Python, PIP, GIL, Flask, Django, Marshmallow,
def
, logging, Pandas, Numpy, AWS Chalice,import
,from
,tuple
,list
, Python exceptions,virtualenv
,.append
,pytz
,TZ
,print
,python3 -c
,os
, PEP, Python Institute, Methods: Dunder methods, Flake8, Python collections, Function decorators in Python, Click python library, Python module, Flower,kwargs
, Black (Python), Python list structure, Mypy,variables
, Casting,try:
, pydoc, argparse, Anaconda,pyenv, setup.py, python3 --version, python3 --help
, Data Classes, raise
Advertising: