小编use*_*726的帖子

从字符串中制作元组列表,

我想用字符串列出元组列表.基本上,给出以下内容,

s = "a b c d"
w = s.split()
Run Code Online (Sandbox Code Playgroud)

我想要下面的元组列表:

[(a, b), (b, c), (c, d)]
Run Code Online (Sandbox Code Playgroud)

我觉得我应该使用append函数和for循环,但我被卡住了.我该怎么做?

python string tuples list

1
推荐指数
1
解决办法
118
查看次数

标签 统计

list ×1

python ×1

string ×1

tuples ×1