开发者

How can I convert a string to a list in python?

开发者 https://www.devze.com 2023-04-06 19:09 出处:网络
Let\'s say I have : my_args = [\"QA-65\"] as the desired result, but in my function, I have: m = re.search(\"([a-zA-Z]+-\\d+)\",line)

Let's say I have :

my_args = ["QA-65"]

as the desired result,

but in my function, I have:

            m = re.search("([a-zA-Z]+-\d+)",line)
            print 'printing m.group(1)'
            print m.group(1)
            m_args = m.group(1)
            print 'my_args '
            print m_args
            print type(m_args)

so that开发者_开发技巧 the type of "m_args" is string, i.e

How can I convert m_args to a list with just one element with the same content as the string?


Perhaps this:

my_args = [my_args]


You do it this way:

m_args = [m_args, ]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号