How to convert a str to a single element list in python

前端 未结 5 458
无人共我
无人共我 2020-12-29 03:08

I have a str variable: var_1 = \"hello\" , and I want to convert it to a single element list, I try this:

>>>         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-29 04:09

    Just put square brackets

    >>> var_1 = "hello"
    >>> [var_1]
    ['hello']
    

提交回复
热议问题