Discuss / Python / 你们当真理解了题目的意思吗。。。

你们当真理解了题目的意思吗。。。

Topic source

打印变量的值 变量是S1='hello,world' 字符串,打印出来是hello,world 哪还有'' 一堆加r和'''就上的,无语

test1_types_and_variables

n = 123 f = 456.789 s1 = 'Hello, world' s2 = 'Hello, \'Adam\'' s3 = r'Hello, "Bart"' s4 = r'''Hello, Lisa!''' print('\nn =', n, '\nf =', f, '\ns1 =', s1, '\ns2 =', s2, '\ns3 =', s3, '\ns4 =', s4)

运行结果

n = 123 f = 456.789 s1 = Hello, world s2 = Hello, 'Adam' s3 = Hello, "Bart" s4 = Hello, Lisa!

终于懂了!!!

云朔天外

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

还是不懂诶,按我的理解题目里变量的赋予值包含了转义符吧?

shanafang9

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

唉,想多了 我这还有更复杂的 print('s4',"=","r'''Hello,","\nLisa!'''")

有这么简单为什么叫习题?

言玉兄

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

感谢

新建了一个小白交流学习群,二维码链接在hiyagg.com,欢迎大神,小白进群交流学习,讨论课后习题。

Yohey__Walker

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

不懂为什么换行符要在单引号里面

Yohey__Walker

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

再看了一遍教程,懂了


  • 1

Reply