小白教程
所有教程
关于
Search
172.69.58.90
172.69.58.90
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 func reversed”的源代码
本页内容
上一节:
Python3_func_map
下一节:
Python_func_import
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:reversed()}}[[Category:python3 built in functions|58]] = Python3 reversed 函数 = [[python3 built in functions|Python3 内置函数]] == 描述 == reversed 函数返回一个反转的迭代器。 === 语法 === 以下是 reversed 的语法: <sample title="" desc="" lang="python" hererun="1"> reversed(seq) </sample> === 参数 === * seq -- 要转换的序列,可以是 tuple, string, list 或 range。 === 返回值 === 返回一个反转的迭代器。 以下展示了使用 tuple 的实例: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/env python3 # 字符串 seqString = 'xiaoBai' print(list(reversed(seqString))) # 元组 seqTuple = ('R', 'u', 'n', 'o', 'o', 'b') print(list(reversed(seqTuple))) # range seqRange = range(5, 9) print(list(reversed(seqRange))) # 列表 seqList = [1, 2, 4, 3, 5] print(list(reversed(seqList))) </sample> 以上实例输出结果为: <sample title="" desc="" lang="python" hererun="1"> ['b', 'o', 'o', 'n', 'u', 'R'] ['b', 'o', 'o', 'n', 'u', 'R'] [8, 7, 6, 5] [5, 3, 4, 2, 1] </sample> [[python3 built in functions|Python3 内置函数]]
返回至“
Python3 func reversed
”。
上一节:
Python3_func_map
下一节:
Python_func_import