-
Notifications
You must be signed in to change notification settings - Fork 2
/
python3.r
146 lines (103 loc) · 3.38 KB
/
python3.r
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
## Python3 ##
#
# Autor= João Batista Ribeiro
# Bugs, Agradecimentos, Críticas "construtivas"
# me envie um e-mail. Ficarei Grato!
# e-mail: [email protected]
#
# Last update: 16/06/2024
#
## python3 simple HTTP server
# https://docs.python.org/2/library/simplehttpserver.html
# https://docs.python.org/3/library/http.server.html
## Start in the folder want to share
cd path/to/share/
## Create server - python3
python3 -m http.server
## Or
python3 -m http.server --help
python3 -m http.server [port]
## Old - python2
python -m SimpleHTTPServer
python -m SimpleHTTPServer [port]
## Access
## Get local IP
/sbin/ifconfig | grep broadcast | awk '{print $2}'
## Print link with default port
echo "http://$(/sbin/ifconfig | grep broadcast | awk '{print $2}'):8000/"
## Localhost:
http://localhost:8000
http://0.0.0.0:8000/
http://127.0.0.1:8000
http://<IP_Address>:8000
## On other machine in same network:
http://<IP>:8000
## ex:
http://192.168.0.105:8000/
## Create virtual environment
# https://docs.python.org/3/tutorial/venv.html
## Create a virtual environment in local path with name my_env
python3 -m venv my_env
## Now activate it, use environment name
## On Windows
my_env\Scripts\activate.bat
## On Unix or MacOS
source my_env/bin/activate
## To deactivate
deactivate
## On conda
conda deactivate
## To install lib
## Install pillow
pip install pillow
## pip cache info
pip cache info
## pip clean cache
pip cache purge
## pip upgrade packages
## List outdated
pip list --outdated
## upgrade
pip install [package] --upgrade
## Install howdoi # Install pip before
pip install howdoi
## Upgrade howdoi
# pip install [package] --upgrade
pip install howdoi --upgrade
## Install packages requirements
pip install -r requirements.txt
## Upgrade all pip packages
pip freeze > requirements.txt
pip install -r requirements.txt --upgrade
## Python3
https://github.com/arbackes/Livro_Python
https://www.w3schools.com/python/default.asp
https://python.swaroopch.com/
## x^y - 4^9 - elevado / power
4**9
= 262144
## int limit
5**262144
## ValueError: Exceeds the limit (4300) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit
import sys
sys.set_int_max_str_digits(0)
5**262144
= 620606987866087...
## int to string
a = 5**262144
b = str(a)
len(b)
= 183231
## Or
len(str(a))
## end and sep
print("Hello World", end="\n")
print("Hello World", end=" ")
print("Hello World", end="")
print('30','11','2023', sep='/', end='\n')
name = "Alice"
age = 30
print("My name is", name, "and I am", age, "years old.", end=" ")
## print format
print("My name is {} and I am {} years old.".format(name, age))
print("My name is {} and I am {} years old.".format("John", age), end="\n\n")