Python 豆知識 — str.partition(sep)
假設有以下字串: s = 'data1: {"title": "abc", "content": "123"}' 當我們想把字串切成 data1 與 {"title": "abc", "content": "123"} 2 個部分的話,多數人應該直覺會想到 s.split(': ')[0] 與 ': '.join(s.split(': ')[1:]) 這個簡單的方法。 但是上述解法有個問
Posted on May 5, 2024 by Amo Chen ‐ 1 min read