简体   繁体   English

关于在python中用几个字符分割字符串的一个函数

[英]about one function that splits a string with several chars in python

this is a function I found on the internet, but I'm not sure what does the line s,res = res,[] mean, can anyone explain this to me? 这是我在互联网上找到的函数,但是我不确定s,res = res,[]s,res = res,[]什么意思,有人可以向我解释吗? Thank you very much! 非常感谢你!

def my_split(s, seps):
    res = [s]
    for sep in seps:
        s, res = res, []
        for seq in s:
            res += seq.split(sep)
            return res
s, res = res, []

Means 手段

s = res
res = []

Replacement of variable in single line. 在单行中替换变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM