题解 | #字符串合并处理#
字符串合并处理
https://www.nowcoder.com/practice/d3d8e23870584782b3dd48f26cb39c8f
import sys word=input().split(' ') new_word=word[0]+word[1] new_tem_word=list(new_word) new_tem_word[::2]=sorted(new_tem_word[::2]) new_tem_word[1::2]=sorted(new_tem_word[1::2]) end_word='' for i in new_tem_word: if '0'<=i<='9' or 'a'<=i<='f' or 'A'<=i<='F': if i.isdigit(): g=bin(int(i))[2:] if len(g)<4: g=(4-len(g))*'0'+g g=hex(int(g[::-1],2))[2:] if g.isalpha(): g=g.upper() else: g=hex(int(bin(int(i,16))[2:][::-1],2))[2:] if g.isalpha(): g=g.upper() end_word=end_word+str(g) else: end_word=end_word+i print(end_word)