[英]How can I convert a string to a list in python?
比方說我有:
my_args = ["QA-65"]
作為期望的結果,
但在我的功能中,我有:
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)
所以“m_args”的類型是字符串,即
如何將m_args轉換為只包含一個與字符串具有相同內容的元素的列表?
也許這個:
my_args = [my_args]
你這樣做:
m_args = [m_args, ]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.