N
N
Nikolay Baranenko2018-03-22 19:53:21
Python
Nikolay Baranenko, 2018-03-22 19:53:21

How to correctly set and read list values ​​from yaml to exclude "\n"?

Hello.
I have a config file
that describes the values ​​like this

url_request:
    STRING_TEMPLATE:
    - str: |
        >result-
    - str: |
        %Y-%m-%d
    - str: |
        1
    - str: |
        _22-00.txt

further in python code i get a list of STRING_TEMPLATE values
STRING_TEMPLATE=yaml_cfg["url_request"]["STRING_TEMPLATE"]

all of them with line breaks \n
[{'str': '>result-\n'}, {'str': '%Y-%m-%d\n'}, {'str': '1\n' '}, {'str': '_22-00.txt\n'}]
How to read or save in Yaml so that there are no hyphens?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-03-22
@drno-reg

Use folded block

- str: >
  >result-

or not use block notation at all
- str: 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question