首页 > IT职业 > IT图书 > python如何取数组后几位?

python中去数组后几位的方法:
一维数组输出最后一位的方法:
output = [1,2,3] print(output[-1])
输出结果:
3
输出后两位:
output = [1,2,3] print(output[-2:])
输出结果:
[2, 3]
二维数组输出最后一位:
output = [[1,2,3], [4,5,6], [2, 5, 6]] print(output[1][-1])
输出结果:
6
更多Python知识请关注Python视频教程栏目。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1627/viewspace-2833758/ ,如需转载,请注明出处,否则将追究法律责任。