gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
Python中的转义字符
- User
Python中的转义字符
- Assistant
Python中的转义字符包括:
-
\n:换行
-
\t:制表符,相当于一个Tab键的宽度
-
\r:回车
-
\b:退格,相当于按下Backspace键
-
\f:换页,相当于按下PageUp键
-
\’:单引号
-
\”:双引号
-
\:反斜线
示例:
print("hello\nworld") # 换行 print("hello\tworld") # 制表符 print("hello\rworld") # 回车 print("hello\bworld") # 退格 print("hello\fworld") # 换页 print('I\'m a student') # 单引号 print("She said, \"I\'m fine.\"") # 双引号 print("C:\\Users\\John\\Desktop") # 反斜线输出:
hello world hello world world helloworld hello world I'm a student She said, "I'm fine." C:\Users\John\Desktop -