[PYTHON] Save a YAML-formatted file in PyYAML

problem

pip install PyYAML When I try to output a YAML file with PyYAML installed in The dictionary as it is came out.

Solution

import yaml

yaml.dump({"key": "value"}, default_flow_style=False)

References

http://pyyaml.org/wiki/PyYAMLDocumentation#Dictionarieswithoutnestedcollectionsarenotdumpedcorrectly

Recommended Posts

Save a YAML-formatted file in PyYAML
Count specific strings in a file
Save the binary file in Python
Save a specific variable in tensorflow.session
Create a binary file in Python
Save the Pydrive authentication file in a different directory from the script
[GPS] Create a kml file in Python
Create a GIF file using Pillow in Python
Read a file containing garbled lines in Python
Create an executable file in a scripting language
How to create a JSON file in Python
Create a MIDI file in Python using pretty_midi
How to read a file in a different directory
Save the setting conditions as a CSV file using UDF Manager in OCTA
File operations in Python
Parse a JSON string written to a file in Python
File processing in Python
Get the file name in a folder using glob
A memorandum to run a python script in a bat file
I want to randomly sample a file in Python
File operations in Python
dict in dict Makes a dict a dict
Output a character string with line breaks in PyYAML
Run a Python file with relative import in PyCharm
Output a binary dump in binary and revert to a binary file
[Sublime Text 2] Always execute a specific file in the project
Try creating a Deep Zoom file format .DZI in Python
Change the standard output destination to a file in Python
How to import a file anywhere you like in Python
[Note] Import of a file in the parent directory in Python
Create a function in Python
Create a dictionary in Python
Download the file in Python
Override save method in django-models
Collaborate in a remote environment
Upload a file to Dropbox
Read and write a file
Make a bookmarklet in Python
Settings for running a test each time you save a file in the editor using watchmedo (watchdog)
Create a dummy data file
Write and read a file
Export a gzip-compressed text file
Display Japanese in JSON file
Draw a heart in Python
Save Time type in SQLAlchemy
Process Splunk execution results using Python and save to a file
Anyway, the fastest serial communication log is left in a file
How to specify a .py file to load at startup in IPython 0.13
Read a file in Python with a relative path from the program
Read the config file in Go language! Introducing a simple sample
Get the formula in an excel file as a string in Python
Get OCTA simulation conditions from a file and save with pandas