python中交换字符串中两个字符

str_temp = cur_map
        if i > j:
            s = i
            t = j
        else:
            s = j
            t = i
        cur_map =  str_temp[ : t] + str_temp[s] + str_temp[t + 1 : s]\
                       + str_temp[t] + str_temp[s + 1 :]
        return cur_map

你可能感兴趣的:(python)