20. 元组变量 t = ('cat', 'dog', 'tiger', 'human'),t[::-1] 的结果是

A){'human', 'tiger', 'dog', 'cat'} B)['human', 'tiger', 'dog', 'cat'] C)运行出错 D)('human', 'tiger', 'dog', 'cat')

解析:

D)('human', 'tiger', 'dog', 'cat')

元组变量 t = ('cat', 'dog', 'tiger', 'human'),t[::-1] 表示从后向前逆序取元素,即('human', 'tiger', 'dog', 'cat')。

Python 元组逆序:t[::-1] 的结果是什么?

原文地址: https://www.cveoy.top/t/topic/oYze 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录