I have tested out some escape sequences. Most of them work, but some of them do not. Why is this?
This is the code I wrote for testing the escape sequences:
# -*- coding: UTF-8 -*-
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split \non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = '''
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
'''
print tabby_cat
print persian_cat
print backslash_cat
print fat_cat
#while True:
# for i in ["/", "-", "|", "\\", "|"]:
# print "%s\r" % i,
print "This should ring a bell \a"
print "Does this have a backspace\b"
print "Printing \"double quotes\" and some \'single quotes\'"
print "Formfeed.\fWill this work?"
print "Linefeed.\nWill this work?"
print "Print the character named name: \N{name}"
print "Print a carriage return.\rWill this work?"
print "A 16 bit unicode character: \u6C34"
print "Let's check this vertical tab: \v\vWhat is this?"
print "This should output an octal value: \111"
print "This should output a hex value: \xAA"
And the output in the terminal:
I'm tabbed in.
I'm split
on a line.
I'm \ a \ cat.
I'll do a list:
* Cat food
* Fishies
* Catnip
* Grass
This should ring a bell
Does this have a backspace
Printing "double quotes" and some 'single quotes'
Formfeed.
Will this work?
Linefeed.
Will this work?
Print the character named name: \N{name}
Will this work?e return.
A 16 bit unicode character: \u6C34
Let's check this vertical tab:
What is this?
This should output an octal value: I
This should output a hex value: �
The ones that do not work are:
- Bell:
\a
- Backspace:
\b
- Character name:
\N{name}
(Solved) - 16 and 32 bit unicode characters:
\u6C34
(Solved)
What should I do to make these escape sequences work?
================EDIT=====================
print u"Print the character named name: \N{BLACK SPADE SUIT}"
print u"A 16 bit unicode character: \u6C34"
Print the character named name: ♠
A 16 bit unicode character: 水
- 16 and 32 bit unicode characters:
\u6C34
- Character name:
\N{name}
These works just fine when preceding the string with au