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']