from pip._internal.cli.main import main
main(['install', 'xlrd'])
#Collecting xlrd
# Downloading xlrd-2.0.1-py2.py3-none-any.whl (96 kB)
# |████████████████████████████████| 96 kB 541 kB/s
# Installing collected packages: xlrd
# Successfully installed xlrd-2.0.1
# WARNING: You are using pip version 21.1.1; however, version 21.2.4 is available.
# You should consider upgrading via the '/opt/.../rvenv/bin/python -m pip install --upgrade pip' command.
import xlrd
xlrd.__version__
# '2.0.1'
main(['freeze'])
# aioredis==1.3.1
# amqp==5.0.6
# argon2-cffi==20.1.0
# asgiref==3.3.4
# ...
pip freeze > requirements.tmp
occurence_count = Counter(map(lambda x:cv2.contourArea(x), contours))
most_common_area = round(occurence_count.most_common(1)[0][0])
Отсеяв лишнее, оставив только дату. При этом, сохранить у test1 тип datatime
date1 = datetime.datetime.fromisoformat('2021-09-08 15:45:40.260000+00:00')
# datetime.datetime(2021, 9, 8, 15, 45, 40, 260000, tzinfo=datetime.timezone.utc)
date1.strftime('%Y-%m-%d')
# '2021-09-08'
date1.date()
# datetime.date(2021, 9, 8)
date1.date().isoformat()
# '2021-09-08'
datetime.datetime.combine(date1.date(), datetime.datetime.min.time())
# datetime.datetime(2021, 9, 8, 0, 0)
import math
a, alpha, x = 10, 10, 10
y1 = math.log(abs(x**3)) + math.tan(alpha)-pow(math.e, a*(x**2)+x)
print(y1)
# OverflowError: (34, 'Result too large')
import math
import decimal
decimal.getcontext().prec = 100
a, alpha, x = 10, 10, 10
y1 = decimal.Decimal(math.log(decimal.Decimal(abs(decimal.Decimal(x)**decimal.Decimal(3))))) \
+ decimal.Decimal(math.tan(decimal.Decimal(alpha))) \
- decimal.Decimal(pow(decimal.Decimal(math.e), decimal.Decimal(a)*(decimal.Decimal(x)**decimal.Decimal(2))+decimal.Decimal(x)))
print(y1)
# -4.339370400623091759291109148627508614055728677394889807059531826625028640984354352252576981241604834E+438
In [1]: import importlib
In [2]: requests.__version__
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-37d800a179a9> in <module>
----> 1 requests.__version__
NameError: name 'requests' is not defined
In [3]: requests = importlib.import_module('requests')
In [4]: requests.__version__
Out[4]: '2.22.0'
import pickle
# An arbitrary collection of objects supported by pickle.
data = {
'a': [1, 2.0, 3, 4+6j],
'b': ("character string", b"byte string"),
'c': {None, True, False}
}
with open('data.txt', 'wb') as f:
# Pickle the 'data' dictionary using the highest protocol available.
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
import pickle
with open('data.txt', 'rb') as f:
# The protocol version used is detected automatically, so we do not
# have to specify it.
data = pickle.load(f)
print(data)
# {'a': [1, 2.0, 3, (4+6j)], 'b': ('character string', b'byte string'), 'c': {None, True, False}}
import re
text1 = '@0'
text2 = '0'
print(text1, text1.startswith('@'))
print(text2, text2.startswith('@'))
print(text1, bool(re.match('^@', text1)))
print(text2, bool(re.match('^@', text2)))
print(text1, text1[:1] == '@')
print(text2, text2[:1] == '@')
# @0 True
# 0 False
# @0 True
# 0 False
# @0 True
# 0 False