Python: Difference between revisions
From DWIKI
m (→Strings=) |
m (→HOWTO) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
*[http://www.python.org/ Homepage] | *[http://www.python.org/ Homepage] | ||
*[ | *[https://www.w3schools.com/python/ w3schools] | ||
*[https://www.tutorialspoint.com/python https://www.tutorialspoint.com/python] | *[https://www.tutorialspoint.com/python https://www.tutorialspoint.com/python] | ||
*[https://wiki.python.org/moin/BeginnersGuide/Programmers Beginners guide] | *[https://wiki.python.org/moin/BeginnersGuide/Programmers Beginners guide] | ||
=HOWTO= | |||
==virtual environment== | |||
===Create virtual environment=== | |||
mkdir myproject | |||
cd myproject | |||
python -m venv venv | |||
source venv/bin/activate | |||
and then you can | |||
pip install whatever | |||
===Leave venv=== | |||
deactivate | |||
==Listen on http== | |||
[https://realpython.com/python-http-server/ Python http server] | |||
python3 -m http.server 8080 | |||
===Leave virtual environment=== | |||
deactivate | |||
===Link python to python3 on Ubuntu=== | |||
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 | |||
=Data types= | |||
==Tuples== | |||
===Tuples methods=== | |||
=Regex= | |||
*[https://docs.python.org/3/howto/regex.html Python Regex] | |||
=Strings= | =Strings= | ||
==Length of string== | ==Length of string== | ||
len(s) | len(s) | ||
==Lists== | |||
===List operators=== | |||
=Regular expressions= | |||
https://docs.python.org/3/library/re.html | |||
=FAQ= | =FAQ= | ||
Line 18: | Line 54: | ||
===update-alternatives: error: no alternatives for python=== | ===update-alternatives: error: no alternatives for python=== | ||
update-alternatives --install /usr/bin/python python $(which python3) | update-alternatives --install /usr/bin/python python $(which python3) 1 | ||
==Leave virtualenv== | ==Leave virtualenv== |
Latest revision as of 14:46, 20 December 2024
Links
HOWTO
virtual environment
Create virtual environment
mkdir myproject cd myproject python -m venv venv source venv/bin/activate
and then you can
pip install whatever
Leave venv
deactivate
Listen on http
python3 -m http.server 8080
Leave virtual environment
deactivate
Link python to python3 on Ubuntu
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Data types
Tuples
Tuples methods
Regex
Strings
Length of string
len(s)
Lists
List operators
Regular expressions
https://docs.python.org/3/library/re.html
FAQ
-bash: python: command not found
Try
update-alternatives --config python
update-alternatives: error: no alternatives for python
update-alternatives --install /usr/bin/python python $(which python3) 1
Leave virtualenv
deactivate