Difference between revisions of "Os (Python library)"
Jump to navigation
Jump to search
(→Other) |
|||
(12 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
===Usage=== | ===Usage=== | ||
− | + | <code>[[import]] os</code> | |
− | |||
===Command execution=== | ===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.environ]]['HOME'] | ||
+ | |||
+ | [[os.getenv]] https://docs.python.org/3/library/os.html#os.getenv | ||
== Example == | == Example == | ||
Line 24: | Line 32: | ||
== Related == | == Related == | ||
* <code>[[import subprocess]]</code> | * <code>[[import subprocess]]</code> | ||
+ | * <code>[[execve]]</code> | ||
+ | * <code>[[from os import environ]]</code> | ||
+ | * <code>[[pathlib]]</code> | ||
== See also == | == See also == |
Revision as of 11:41, 17 May 2022
Usage
import os
Command execution
os.system("your_code ")
File management
Other
os.path.dirname
os.path.basename
os.path.realpath
os.environ['HOME']
os.getenv https://docs.python.org/3/library/os.html#os.getenv
Example
#!/usr/bin/env python3 import os os.system("echo 'Hello World'")
Related
See also
- 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: