>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
... print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
goods_dict = [
{'id': '1', 'goods': 'macbook 16 pro', 'brand': 'Apple'},
{'id': '2', 'goods': 'ThinkPad X1 Extreme Gen 3', 'brand': 'lenovo'},
{'id': '3', 'goods': 'XPS 17 9710 Silver', 'brand': 'Dell'}
]
#лист акссесуаров
add_lists = [
['Apple','стилус'],
['lenovo','коврик'],
['hp','мышь'],
['asus','флешка']
]
for item in add_lists:
item_brand = item[0]
item_name = item[1]
print(item_brand)
print('-',item_name)
for good in goods_dict:
good_brand = good['brand']
print('--',good_brand)
if not good.get('accessory'):
if good_brand == item_brand:
good['accessory'] = item_name
else:
good['accessory'] = None
for good in goods_dict:
print(good)
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = []
for item in old_list:
g_dict.append(dict(zip(cols, item)))
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = [dict(zip(cols, item)) for item in old_list]
data_dict = {
'ФИО': {1: 'Иванов', 2: 'Петров', 3: 'Jonson'}
'работа': {1: 'грузчик', 2: 'менеджер', 3: 'менеджер менеджера'}
}
for key in data_dict.keys():
for i in data_dict[key].values():
print(f'{key} -> {i}')
if len(list_dirname) == 0:
print('Ничего не найдено')
for line in open('1.txt'):
line = line.strip()
if line.startswith("ip"):
print(line.split("=")[1].strip())
import re
files = ['новая папка', 'games', 'install', 'фото', 'музыка']
search = ['папка', 'фотки', 'музло']
finds = set()
chars_find = re.compile(r'\w{3}')
for file in files:
for world_search in search:
for world in chars_find.findall(world_search):
if world in file:
finds.add(file)
print(finds)
from fuzzywuzzy import fuzz
files = ['новая папка', 'games', 'install', 'фото', 'музыка']
search = ['папка', 'фотки', 'музло']
result = []
for im in search:
for fil in files:
if fuzz.partial_ratio(im, fil) > 50:
result.append(fil)
print(result)
# ['новая папка', 'фото', 'музыка']
.exe.vmoptions
файлы из папки с конфигурацией PhpStorm: