blob: 865aa963437af490cbaee610a282c0d099c3afc8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# Desc: Python is a high-level programming language.
# Basic example of server with python
# Will start a Web Server in the current directory on port 8000
# go to http://127.0.0.1:8000
# Python v2.7
python -m SimpleHTTPServer
# Python 3
python -m http.server 8000
# SMTP-Server for debugging, messages will be discarded, and printed on stdout.
python -m smtpd -n -c DebuggingServer localhost:1025
# Pretty print a json
python -mjson.tool
# Generate requirements.txt
pipreqs /path/to/project
# Tips
# Ressources available in : cheat python_ressources
Input: décoder avec `decode()`.
Output: encoder avec `encode('utf-8')`
lors de l'ouverture d'un fichier:
```
from codecs import open
# open() de codec à exactement la même API, y compris avec "with"
f = open('fichier', encoding='encoding')
```
# Types
bytes == bytearray
# non mutable (non modifiable)
bytes
tuple
# mutable (modifiable)
bytearray
# For bytes and bytearray show hex value of each char
[hex(i) for i in header]
# For string show hex value of each char
[hex(ord(c)) for c in header]
# Opencv with gstreamer
# Gstreamer not on pipy but present when building...
git clone --recursive https://github.com/skvark/opencv-python.git
git checkout -b 25
ENABLE_CONTRIB=ON python setup.py install
# package developement
virtualenv .venv_dev
source .venv_dev/bin/activate
pip install -e . # for install package in dev mode
# virtualenv with custom python version
mkvirtualenv projectpy2 --python=python2.7
|