My file reads user input (like userid, password..). And sets the data to x.yml file.
The content of x.yml file is
{user: id}
But instead I want the content to be as
user: id
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As mentioned in the comments, the python YAML library is the right tool for the job. To get the output you want, you need to pass the keyword argument
default_flow_style=Falsetoyaml.dump:The file “output_file.yml” will contain:
Further information on how to customise
yaml.dumpare available at http://pyyaml.org/wiki/PyYAMLDocumentation.