from typing import Callable
def encode(code: int) -> int:
""" Encode unicode code point of the character. """
return code * 2 - 9
def decode(code: int) -> int:
""" Decode unicode code point of the character. """
return (code + 9) // 2
def process(password: str, func: Callable[[int], int]) -> str:
""" Encode/decode password. """
return ''.join([chr(abs(func(ord(c)))) for c in password])
if __name__ == '__main__':
password = input('Введите пароль: ')
mode = input("Выберите режим (Code/Decode): ").capitalize()
if mode.startswith('Code'):
print(process(password, encode))
elif mode.startswith('Decode'):
print(process(password, decode))
else:
print('Вы ввели {}. Данного режима не существует.'.format(mode))
if __name__ == '__main__':
df = { 'name': False }
cfg = df.copy()
cfg['name'] = True
cfg = df.copy()
print(df)
print(cfg)
import numpy as np
def f(x: np.ndarray, eps: float) -> np.ndarray:
y = np.empty_like(x)
y[x < -eps] = 0
mask = np.logical_and(-eps <= x, x <= eps)
y[mask] = 0.5*(1+x[mask]/eps+np.sin(np.pi*x[mask]/eps)/np.pi)
y[eps < x] = 1
return y
if __name__ == '__main__':
x = np.linspace(-2, 2, num=11)
print(f(x, 1))
fig, (ax1, ax2) = plt.subplots(2, 1, sharex='all', figsize=(640/my_dpi, 2*480/my_dpi), dpi=my_dpi)
def resource_path(relative):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative)
else:
return os.path.join(os.path.abspath("."), relative)
self.setWindowIcon(QtGui.QIcon(resource_path('runcubit_gui.ico')))
self.tray_icon.setIcon(QtGui.QIcon(resource_path('runcubit_gui.ico')))
и если написать в функции return она один раз выполнится и выйдет из цикла for
хотел бы отправить текст что такой то файл разархивирован в textEdit на форме
def extract(year, month):
return 'year = '+year+', month = '+month
def keyPressEvent(self, e):
if e.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:
self.WikiGo()
else:
super(MyWindow, self).keyPressEvent(e)
s = r'\u0410 \u0443 \u043c\u0435\u043d\u044f \u0449\u0430\u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0447\u043c\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434 \u043e\u043a\u043d\u0430\u043c\u0438!'
print(s.encode('ascii').decode('unicode_escape'))
А у меня щас вот такое чмо стоит под окнами!