2
我有這個..除去空間 - 的Python 3
the_tuple = (1,2,3,4,5)
print ('\"',the_tuple[1],'\"')
顯示
" 2 "
我怎樣才能輸出到顯示"2"
?
我有這個..除去空間 - 的Python 3
the_tuple = (1,2,3,4,5)
print ('\"',the_tuple[1],'\"')
顯示
" 2 "
我怎樣才能輸出到顯示"2"
?
用途:
print ('\"',the_tuple[1],'\"', sep='')
^^^^^^
注意,這些逃逸是完全沒有必要的:
print ('"', the_tuple[1], '"', sep='')
甚至更好,使用字符串格式化:
print ('"{}"'.format(the_tuple[1]))
非常感謝喬恩! –