Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有类似的句子
// string1 = value1 // string2 = value2.....
依此类推,我怎样才能使用 python 只获取“值”
print [line.split('=',1)[-1].strip() for line in s.splitlines()]
>>> strs=""" // string1 = value1 // string2 = value2 """ >>> [x.split('=')[1].strip() for x in strs.split('\n') if x.strip()] ['value1', 'value2']