
# Nico
# 时间:2021/3/28 21:26
#转义字符
print('hello\nworld') #n--newline的首字符表示换行
print('hello\tworld') #\t占4个字符,此处为3个
print('helloooo\tworld') #此处为4个
print('hello\rworld') #r--reverse光标返回到首字母
print('hello\bworld') #b--backspace
print('http:\\\\www.baidu.com') #输出\
print('老师说:大家好\'')
#原字符:不希望字符串中的转义字符起作用,就使用原字符,就是在字符串之前加上r或者R
#注意事项:最后一个字符不能是\
print(r'hello\nworld')
本文介绍了Python中常用的字符串转义字符,包括
用于换行, 表示制表符,
使光标回到行首,是退格符,以及如何使用r前缀避免转义。同时讲解了原始字符串的使用方法。
1152

被折叠的 条评论
为什么被折叠?



