题解 | #字符串变形#
字符串变形
http://www.nowcoder.com/practice/c3120c1c1bc44ad986259c0cf0f0b80e
反转大小写字母转换用swapcase,倒序排列【::-1】,然后就简单明了了
class Solution: def trans(self, s, n): # write code here slict = s.swapcase().split(' ') slict = slict[::-1] slict = ' '.join(slict) return slict # for i in range(n): # j = i # while j<n and s[j] !=' ': # j += 1 # reversed(s.begin()+i, s.begin()+j) ###//begin如何用python语言还没查到 # i=j # return s.swapcase() # for i in n: # if s[i] != ' ' and s[i] <='Z' and