登录社区云,与社区用户共同成长
邀请您加入社区
以 \n 为例输出1)在字符串之前值直接加 r2)对于变量中包含的,使用 %r如果不这么使用,就会直接换行输出结果了# -*- coding: utf-8 -*-if __name__ == '__main__':str1 = "hello\npython"print(str1)# hello# pythonprint('%r' % str1)# 'hello\npython'str2 = r"h
1)在字符串之前值直接加 r 2)对于变量中包含的,使用 %r 如果不这么使用,就会直接换行输出结果了
# -*- coding: utf-8 -*- if __name__ == '__main__': str1 = "hello\npython" print(str1) # hello # python print('%r' % str1) # 'hello\npython' str2 = r"hello\nworld" print(str2) # hello\nworld
CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!
更多推荐
用 OpenAI Assistants 做大模型应用开发
1 小时解读鸿蒙 10 大热点问题
扫一扫分享内容
所有评论(0)