Jump to content
You must now use your email address to sign in [click for more info] ×

In Python 3, how do you use """ and escape sequences?


Recommended Posts

I'm currently studying Python and wanted to try all of the escape sequences, however my code appears to have a fault. Could you please assist me in locating it?

My Code:

string = """backslash - \\\nsingle quote - \'\ndouble quote - \"
ASCII bell - \a Lorem
ASCII backspace - \b Lorem
ACII formfeed - \f Lorem
Unicode - \N{prabhu} Ipsum
Carriage return - \r Ipsum
16 bit Hex value - \u1234
32 bit Hex value - \U12345678 ASCII Vertical tab - \v
Octal value character - \123
Hex value - \x12 
"""

print(string)

Output:

Error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 137-146: unknown unicode character name

 

Link to comment
Share on other sites

  • Staff

Hi @Mobo01,

Welcome to the Affinity Forums :)

These forums are for technical support, bug reporting, work/resource sharing and discussions relating to the Affinity apps - and are not the place for other questions regarding Python.

I would recommend a more generic site for this, such as Stack Overflow.

I have locked this thread to prevent further replies, and we ask that you do not continue to make such posts here on the Affinity Forums.

Many thanks for your understanding!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.