简体   繁体   中英

How do I add characters like @, /, \, * in a string in Python, without it reading it as an escape sequence

I am trying to send a message on twilio. The message includes an ASCII artwork that I have made. It contains characters like *, /, \\, " and #. When I add my drawing in a python string, it reads it as an escape sequence, giving me a bunch of unintended errors. How do I reformat my code so that python prints anything that is within the strings as is, without trying to edit it as an escape sequence.

message = client.messages.create(
                     body= """                  


      .---------. | == |
      |.-"""""-.| |----|
      ||       || | == |
      ||       || |----|
      |'-.....-'| |::::|
      `"")---(""` |___.|
     /:::::::::::\" _  "
    /:::=======:::\`\`\
jgs `"""""""""""""`  '-'


                     """

s="\\\\" is a single backslash. You escape escaping.

When copy-pasting, use replace command in your editor (Ctrl+H)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM