-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaps.py
executable file
·37 lines (34 loc) · 1.21 KB
/
caps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
import random
import argparse
from pypinyin.core import lazy_pinyin
# 随机将文本中的字母转换大小写
class str_of_chitang(str):
def chitang(self):
text=self
upper = False
text = "".join(lazy_pinyin(text))
for i in range(len(text)):
if text[i].isalpha():
if upper:
text = text[:i] + text[i].upper() + text[i+1:]
upper = False
else:
text = text[:i] + text[i].lower() + text[i+1:]
upper = True
#感谢 None 大佬的支持!
"""
if random.randint(0,1) == 1:
text = text[:i] + text[i].upper() + text[i+1:]
else:
text = text[:i] + text[i].lower() + text[i+1:]
"""
return text
def main():
parser = argparse.ArgumentParser(description="仿池沼的大小写114514写的程序")
parser.add_argument("text", help="输入的文本,可以是中文,也可以是Homo语")
args = parser.parse_args()
#print(random_case(args.text))
print(str_of_chitang(args.text).chitang())
if __name__=='__main__':
main()