In [146]: "input"[::-1] # from back to the begining. Equivalent to: "input"[len("input")::-1]
Out[146]: 'tupni'
In [147]: "input"[0::-1] # from back to the 0'th (i.e. first) element from back
Out[147]: 'i'
In [148]: "input"[1::-1] # from back to the 2ed element from back
Out[148]: 'ni'
In [151]: "input"[len("input")::-1] # from back to the last element from back (alterantive way)
Out[151]: 'tupni'
也许这些例子可以说明这一点:
相关问题 更多 >
编程相关推荐