人間夜行

一切の有為の法 夢幻泡影の如し

毫无意义的神秘转换

| 评论

文如其名。因为很简单,所以直接上代码。e2f.py和f2e.py成对使用。

因为要求Python 3,所以就不制作Elephantus版本了。

e2f.py:

#!/usr/bin/env python3
# coding: utf8
CONS = 'BbCcDdFfGgHhJjKkLlMmNnPpQqRrSsTtVvWwXxYyZz'
e = input()
for i in range(len(e)):
    ch = e[i]
    if ch in 'EIOUeiou':
        print(ch, end = '')
    elif ch == 'a':
        print('æ', end = '')
    elif ch == 'A':
        print('Æ', end = '')
    elif i != len(e) - 1 and e[i + 1] not in 'AEIOUaeiou' and e[i] in CONS:
        print(ch + 'a', end = '')
    elif i == len(e) - 1 and e[i] in CONS:
        print(ch + 'a', end = '')
    else:
        print(ch, end = '')
print()
f2e.py:
#!/usr/bin/env python3
# coding: utf8
e = input()
for i in range(len(e)):
    ch = e[i]
    if ch == 'æ':
        print('a', end = '')
    elif ch == 'Æ':
        print('A', end = '')
    elif ch == 'a':
        pass
    else:
        print(ch, end = '')
print()
 

评论