from pymongo import MongoClient #wdqdqwdqwdqw def clean_tags_in_database(): client = MongoClient('mongodb://localhost:27017/') db = client['Manga'] collection = db['Hentai_Manga'] for manga in collection.find(): if 'tags' in manga: cleaned_tags = [tag.strip() for tag in manga['tags'] if tag.strip()] if cleaned_tags != manga['tags']: collection.update_one( {'_id': manga['_id']}, {'$set': {'tags': cleaned_tags}} ) print("Теги успешно очищены от пробелов") # Вызовите эту функцию один раз clean_tags_in_database()