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;'