1

When i try to print \v or \f i get gender symbols instead:

screenshot

Note also that I'm a complete beginner at programming.

edit: Seems like i didnt write clear enough, i dont want to write \v or \f but the escape sequence created by them, i dont know what they exactly do but i dont think this is their meant function-

Letalone
  • 37
  • 3

4 Answers4

2

You are trying to print special characters, e.g., "\n" == new line. You can learn more here: Python String Literals.

Excerpt:

In plain English: String literals can be enclosed in matching single quotes (') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and use different rules for interpreting backslash escape sequences.

The r tells it to print a "raw string."

Python 2.7ish:

print r"\v"

Or, you can escape the escape character:

print "\\v"

Or, for dynamic prints:

print "%r" % ("\v",)
James
  • 2,488
  • 2
  • 28
  • 45
1

You need to cancel out \ by using \\ the \ character is used for special cases.

try

print '\\t'
print '\\v'
Brandon Nadeau
  • 3,568
  • 13
  • 42
  • 65
1

Try print '\\v' or print r"\v"

matthias_h
  • 11,356
  • 9
  • 22
  • 40
Name
  • 179
  • 1
  • 8
0

Try this;

print (r"\n")

r is good for escaping special characters.

GLHF
  • 3,835
  • 10
  • 38
  • 83