从打印输出中删除空间 - Python 3

Ste*_*nes 2 python python-3.x

我有这个..

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"

Jon*_*nts 8

使用:

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)