题解 | #字符串合并处理#
字符串合并处理
https://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
str1, str2 = input().split() str3 = list(str1+str2) str3[::2] = sorted(str3[::2]) str3[1::2] = sorted(str3[1::2]) res = [] for i in str3: if i in '0123456789abcdefABCDEF': tmp = bin(int(i,16))[2:].rjust(4,'0')[::-1] # 按照16进制进解析成二进制 r = hex(int(tmp,2))[2:].upper() # 按照二进制转换成16进制 res.append(r) else: res.append(i) for i in res: print(i,end='')