Discuss / Python / 交作业啦

交作业啦

Topic source

BillCode

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

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

Orz_lq

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

“请打印出以下变量的:”你这是耍滑头啊

王昱华_Leo

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

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

jor弟

#4 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!''')

这个才对 上边教程说的很清楚,\n表示换行,其他的比如' " \ 均需要转译字符\来转译

``` print('n =',123) print('f =',456789e-3) print('s1 =','\'Hello,','world\'') print('s2 = \'Hello, \\'Adam\\'\'') print('s3 = r\'Hello, \"Bart\"\'') print('s4 = r\'\'\'Hello,\nLisa!\'\'\'')


  • 1

Reply