python - 我如何从Python中的s[-4 :] to s[slice(? ??)] 进行翻译?不是“s[切片(s, len(s))]”

标签 python string slice

我知道s[slice(s, len(s))]会起作用,
但有可能无法获取字符串的长度,
并且仍然使用Python中的内置方法slice
看来没有办法解决

最佳答案

所有切片部分的“null”值为None

slice(-4, None)

关于python - 我如何从Python中的s[-4 :] to s[slice(? ??)] 进行翻译?不是“s[切片(s, len(s))]”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47959029/

相关文章:

arrays - Go slice 中的长度和容量

python - 安装 python reddit api 包装器模块

pointers - slice 结构行为

html - 制作 flex 阴影的最佳方法

c++ - 给定 1000 个长度为 100 的字符串,找出最小的唯一子字符串的长度

c++ - 使用字符串的任何缺点(C++)

ios - swift 3 错误 : [_SwiftValue pointSize] unrecognized selector sent to instance

python - 我如何通过 boto3 获取 aws 卷的可用大小

python:导入引用全局范围的函数

python - 如何识别哪个包出现 AttributeError : 'module' is referring to?