'1'.center(2021, '0') == '0'*1010 + '1' + '0'*1010
Задачи по питону и машинному обучению: алгоритмы, функции, классы, регулярные выражения, итераторы, генераторы, ООП, исключения, numpy, pandas, matplotlib, scikit-learn, TensorFlow и др. #Python #ml
'1'.center(2021, '0') == '0'*1010 + '1' + '0'*1010
''.center(5, '*') == '*'.ljust(5, '*')
text = 'ABC'
x = text.ljust(5, '*').rstrip('*').rjust(4, '*')
print(x)s = "hello, Вася"
s1 = s.encode('ascii', 'ignore').decode()
print(s1)import unicodedata
x = unicodedata.category('0')
print(x)x = {ord("a"): "0", ord("b"): "1", ord("c"): None}
s = "aacbb"
s1 = s.translate(x)
print(s1)s = "+a+"
s_new = s.replace('+', '') + s.strip('+')
print(s_new)s = "**hello**"
import unicodedata
x = 'ñ'
t1 = unicodedata.normalize('NFC', x)
t2 = unicodedata.normalize('NFD', x)
print(len(t1), len(t2), t1 == t2)