telebot.some_method()
писать просто some_method()
.merged_list = list()
for f in list_1:
for b in list_2:
if f['id'] == b['company']:
item = {
'company': b['company'],
'base': b['base'],
'price': b['price'],
'name': f['name'],
'disabled': f['disabled']
}
if f.get('retentionType', False):
item['retentionType'] = f['retentionType']
merged_list.append(item)
cities= {
'г. Москва': [
'Москва', 'Moscow', 'Moscow > Moskva', 'г. Москва', 'г.Москва', 'Moskva (Moscow)'
],
'г. Калиниград': [
'Калининград', 'г.Калининград', 'Kaliningrad (Konigsberg)'
]
}
addresses_folder = [
('Moscow > Moskva, ул. xxx, д. xxx' , 'Moscow > Moskva, ул. xxx, д. xxx'),
('Kaliningrad (Konigsberg), ' , 'Kaliningrad (Konigsberg), ')
]
for address in addresses_folder:
address_city = address[0].split(',')[0]
for city, values in cities.items():
if address_city in values:
print(city)
г. Москва
г. Калиниград
In [1]: text = 'background:red;border-color:rgba(255,255,255,0);color:#0ff;'
In [2]: text = text[:text.find(';color:')] + '#FFFFF;'
In [3]: text
Out[3]: 'background:red;border-color:rgba(255,255,255,0)#FFFFF;'
In [1]: import re
In [2]: text = 'background:red;border-color:rgba(255,255,255,0);color:#0ff;'
In [3]: to_replace = '#FFFFF'
In [4]: text = text.replace(re.search(r'(^|[^-])color:(.*?)\;', text).group(2), to_replace)
In [5]: text
Out[5]: 'background:red;border-color:rgba(255,255,255,0);color:#FFFFF;'
import subprocess
a = subprocess.check_output('youtube-dl -параметры', shell=True)
>>> foo = [line.strip() for line in open('foo.txt', 'r')]
>>> foo
['foo', 'bar']
foo = some_string.split('\n')
def function1(string):
print(string+'\nfunction1')
def function2(string):
print(string+'\nfunction2')
def function3(string):
print(string+'\nfunction3')
functions = {
'function1': ['1','function1'],
'function2': ['2','function2'],
'function3': ['3','function3']
}
call_func = input()
for func, keys in functions.items():
if call_func in keys:
eval(f'{func}(call_func)')
break