返回列表 发帖
回复 12# /zhqsystem/zhq


    如果你平时关注的是解决问题而非语言本身,时间久了自然都会接触一点...

TOP

试着写写 python
str='asdfsD1df'
def l2u(str):
ret=''
for c in str:
ret += chr(ord(c)&(0xff^0x20)) if c.isalpha() else c;
return ret
def u2l(str):
ret=''
for c in str:
ret += chr(ord(c)|0x20) if c.isalpha() else c;
return ret
print (l2u(str))
print (u2l(str))COPY
1

评分人数

TOP

呃,套用了 c 的算法:
'a' == 0x60
'A' == 0x40
0xff^0x20 == 0b11111011
0x20 == 0b00000100
'a'  & (0xff^0x20) = 'A'
'A'  | 0x20 = 'a'COPY
1

评分人数

TOP

回复 21# 依山居


    啥意思,直接加上不就好了

TOP

返回列表