Работа с YAML-Файлами в Python с Помощью Библиотеки PyYAML
PyYAML позволяет эффективно работать с файлами в формате YAML (YAML Ain't Markup Language), который широко используется для конфигураций, настроек и обмена данными в структурированной форме.
import yaml
data_to_write = {'name': 'John Doe', 'age': 30, 'city': 'Example City'}
with open('example.yaml', 'w') as file:
yaml.dump(data_to_write, file, default_flow_style=False)
with open('example.yaml', 'r') as file:
loaded_data = yaml.safe_load(file)
print(f"Загруженные данные: {loaded_data}")
Результат (файл example.yaml):
age: 30
city: Example City
name: John Doe
В этом примере мы используем PyYAML для записи словаря data_to_write в файл example.yaml и затем загружаем данные из этого файла обратно в переменную loaded_data.
Библиотека PyYAML предоставляет удобные средства для работы с данными в формате YAML в Python. Будь то сохранение конфигураций, обмен структурированными данными или другие сценарии, где YAML имеет преимущество, PyYAML обеспечивает легкость в использовании и читаемый код🐍
#python#yaml#pyyaml
#Python
🐍
The Python Mega Course: Build 10 Real World Applications
Become a Python programmer by learning how to build any Python program from scratch, GUIs, web apps, APIs, and more.
🌟 4.6 - 57462 votes
💰 $84.99
🗣️: Ardit Sulce
🔗Link
-----
Main channel:@repo_science
Coupons:@freecoupons_reposcience
-----
#Python
🐍
Intermediate Python: Solidify your Python Understanding And Build Apps
Let us build our understanding even better working with Python hands-on
🔗Link
-----
Canal principal:@repo_science
Cupones:@freecoupons_reposcience
-----
#Python
🐍
Como todos conocen #Python es un lenguaje de alto nivel de programación e interpretado cuya filosofía hace hincapié en la legibilidad de su código y se utiliza para desarrollar aplicaciones de todo tipo.
A sugerencia de ustedes hemos creado un grupo donde recopilaremos todo el material disponible agrupado por temas, al que pueden unirse aquí:
👇
🔗Link
-----
Canal principal: @repo_science
Cupones: @freecoupons_reposcience
-----
📰 JDownloader site hacked to replace installers with Python RAT malware
The website for the popular JDownloader download manager was compromised earlier this week to distribute malicious Windows and Linux installers, with the Windows payload found deploying a Python-based remote access trojan.
🔗 Source: https://www.bleepingcomputer.com/news/security/jdownloader-site-hacked-to-replace-installers-with-python-rat-malware/
#linux#python
📰 PyPI Packages Deliver ZiChatBot Malware via Zulip APIs on Windows and Linux
Cybersecurity researchers have discovered three packages on the Python Package Index (PyPI) repository that are designed to stealthily deliver a previously unknown malware family called ZiChatBot on Windows and Linux systems."While these wheel packages do implement the features described on their PyPI web pages, their true purpose is to covertly deliver malicious files," Kaspersky.
🔗 Source: https://thehackernews.com/2026/05/pypi-packages-deliver-zichatbot-malware.html
#linux#python
📰 LiteLLM loses game of Trivy pursuit, gets compromised
Python interface for LLMs infected with malware via polluted CI/CD pipeline Two versions of LiteLLM, an open source interface for accessing multiple large language models, have been removed from the Python Package Index (PyPI) following a supply chain attack that injected them with malicious credential-stealing code.…
🔗 Source: https://go.theregister.com/feed/www.theregister.com/2026/03/24/trivy_compromise_litellm/
#python#opensource