刷题刷出新高度,偷偷领先!偷偷领先!偷偷领先! 关注我们,悄悄成为最优秀的自己!

单选题

能输出下面字符串的是?( ) what's this? it's an "apple"

A
print("what\'s this?\nit\'s an \"apple\"")
B
print("what's this? it's an \"apple\"")
C
print('what's this?\nit's an "apple"')
D
print("what\'s this?\nit\'s an "apple\"")
使用微信搜索喵呜刷题,轻松应对考试!

答案:

A

解析:

【喵呜刷题小喵解析】在Python中,字符串需要用引号括起来,单引号和双引号都可以。字符串内的单引号或双引号需要使用转义字符`\`来标识。所以,选项A中的`print("what's this?\nit's an \"apple\"")`是正确的,因为它使用了转义字符`\`来标识字符串内的单引号和双引号。选项B、C、D中的字符串要么没有用引号括起来,要么没有用转义字符`\`来标识字符串内的单引号和双引号,因此都是错误的。
创作类型:
原创

本文链接:能输出下面字符串的是?( ) what's this? it's an "apple"

版权声明:本站点所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明文章出处。

让学习像火箭一样快速,微信扫码,获取考试解析、体验刷题服务,开启你的学习加速器!

分享考题
share