Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

Escape Characters ใน Python

ตารางต่อไปนี้เป็นรายการ escape หรือ non-printable characters ที่สามารถแทนได้ด้วย backslash notation

Escape character จะถูกตีความ ใน single quoted และ double quoted strings ทั้งคู่

Backslash notation Hexadecimal character Description
\a 0x07 Bell หรือ alert
\b 0x08 Backspace
\cx Control-x
\C-x Control-x
\e 0x1b Escape
\f 0x0c Formfeed
\M-\C-x Meta-Control-x
\n 0x0a Newline
\nnn Octal notation โดย n อยู่ในช่วง 0.7
\r 0x0d Carriage return
\s 0x20 Space
\t 0x09 Tab
\v 0x0b Vertical tab
\x Character x
\xnn Hexadecimal notation โดย n อยู่ในช่วง 0.9, a.f, หรือ A.F