Python - is there a “don't care” symbol for tuple assignments?

前端 未结 9 1905
你的背包
你的背包 2020-12-03 04:17

Given a string \"VAR=value\" I want to split it (only) at the first \'=\' sign (< value > may contain more \'=\' signs), something like this:

<         


        
9条回答
  •  独厮守ぢ
    2020-12-03 04:54

    Really strange question, because you can do just:

    var, _, value = s.partition(sep)
    

    and don't care about _ variable, but _ is just a name as sep, as var or value. By the way use str.split

    >>> var, value = "VAR=value".split('=')
    >>> var, value
    ('VAR', 'value')
    >>> 
    

提交回复
热议问题