subprocess

main
Tran Hau 2020-06-09 01:09:04 +07:00
parent fb4ab0a41c
commit d25a6bf32d
3 changed files with 15 additions and 14 deletions

View File

@ -0,0 +1,10 @@
# [subprocess](https://docs.python.org/3/library/subprocess.html)
```python
import subprocess
subprocess.run(["ls", "-a"])
# Stop when run error
subprocess.run(["exit 1"], check=True)
```

View File

@ -1,22 +1,12 @@
# venv
# [venv](https://docs.python.org/3/library/venv.html)
Python venv is Python Virtual Environment.
Why do we need to use Python venv?
Because we don't want to mess up with Python packages which are stored in different location: system directories, user directories, ...
Assume you use Python 3 and Linux.
---
Python venv stores everything in a local directory.
Inside chosen directory, run:
Creating virtual environments:
```sh
python -m venv venv
python3 -m venv /path/to/venv
```
Now you can use venv with:
Activate:
```sh
# Bash

View File

@ -39,6 +39,7 @@
- [Python](Development/python/README.md)
- [venv](Development/python/venv.md)
- [argparse](Development/python/argparse.md)
- [subprocess](Development/python/subprocess.md)
- [Docker](Development/docker.md)
- [Redis](Development/redis.md)
- [Prometheus](Development/prometheus.md)