dive into python P350 移除连续重复的字符串元素 b='abccdefekjllj' def remove(): a2=b[0] for i in b[1:]: if a2[-1]!=i: a2+=i print a2 #abcdefekjlj