我有这个..
the_tuple = (1,2,3,4,5)
print ('\"',the_tuple[1],'\"')
Run Code Online (Sandbox Code Playgroud)
展示
" 2 "
Run Code Online (Sandbox Code Playgroud)
如何才能显示输出"2"?
使用:
print ('\"',the_tuple[1],'\"', sep='')
^^^^^^
Run Code Online (Sandbox Code Playgroud)
请注意,这些转义完全没必要:
print ('"', the_tuple[1], '"', sep='')
Run Code Online (Sandbox Code Playgroud)
甚至更好,使用字符串格式:
print ('"{}"'.format(the_tuple[1]))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3705 次 |
| 最近记录: |