Is it possible to escape a hash sign (#) from a multiline text?
...
-
my_story: |
Line 1
Line 2
# Hash line
What I was hoping to get is:
array {
'my_story' => 'Line 1
Line 2
# Hash line'
}
If I wrap the hash line with quotes I get them in the text:
'Line 1
Line 2
"# Hash line"'
Any ideas..?
What you wrote is perfectly fine and '#' should be correctly processed. The following code works just fine in Python 3 (pyyaml)
data="""
-
my_story: |
Line 1
Line 2
# Hash line
"""
import yaml
deserializedData = yaml.load ( data )
print ( deserializedData[0]['my_story'] )
The above line prints
Line 1
Line 2
# Hash line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With