Discuss / Python / 小白求助,关于练习题s3、s4

小白求助,关于练习题s3、s4

Topic source

我仿照s3的代码

s3 = "r'Hello,\"Bart\"'"
print('s3 =',s3)

将s4代码从

s4 = r'''Hello,
Lisa!'''
print('s4 =',s4)

改为

s4 = "r'''Hello,
Lisa!'''"
print('s4 =',s4)

提示错误:SyntaxError: invalid character in identifier

只知道""'''...'''冲突,但是不知道怎么改

2802房

#2 Created at ... [Delete] [Delete and Lock User]

print(r"""n = 123 f = 456.789 s1 = 'Hello, world' s2 = 'Hello, \'Adam\'' s3 = r'Hello, "Bart"' s4 = r'''Hello, Lisa!'''""")

2802房

#3 Created at ... [Delete] [Delete and Lock User]

s4 = "r'''Hello,\nLisa!'''" print('s4 =',s4)

今天回顾时候才看到回答,已经清楚了,感谢


  • 1

Reply