Skip to content

Commit 839b8e1

Browse files
author
ranlh
committed
update by: study
1 parent d1e9113 commit 839b8e1

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

gendomains.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import random
2+
3+
order = input("Please input:\n 字母加数字选择 1:\n 全字母选择2:\n 全数字选择3:\n 清空文本按 d: ")
4+
tmplist = []
5+
6+
list1 = ['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a','1','2','3','5','6','7','8','9']
7+
8+
list2 = ['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a']
9+
10+
list3 = ['1','2','3','5','6','7','8','9']
11+
12+
namepath ='C:\\users\\hoo\desktop\\domains.txt'
13+
14+
if order == '1':
15+
tmplist = list1
16+
elif order == '2':
17+
tmplist = list2
18+
elif order == '3':
19+
tmplist = list3
20+
elif order == 'd':
21+
print('正在清除数据...')
22+
with open(namepath, 'w') as f:
23+
f.write('')
24+
print('完成 !')
25+
def write_txts():
26+
tname = set()
27+
num = input("Please input 生成长度:")
28+
startstr = input("enter startstr: ")
29+
endstr = input("enter endstr: ")
30+
print("Please wait a moument")
31+
for i in range(590):
32+
ch = startstr + ''.join(i for i in random.sample(tmplist, int(num))) + endstr
33+
tname.add(ch)
34+
print("All about %s donames." % len(tname))
35+
for ch in tname:
36+
with open(namepath, 'a') as f:
37+
f.write(ch+'\n')
38+
if order != 'd':
39+
write_txts()

recur.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
# 利用递归函数计算阶乘
5+
# N! = 1 * 2 * 3 * ... * N
6+
def fact(n):
7+
if n == 1:
8+
return 1
9+
return n * fact(n-1)
10+
11+
print('fact(5) =', fact(5))
12+
13+
# 利用递归函数移动汉诺塔:
14+
def move(n, a, b, c):
15+
if n == 1:
16+
print('move', a, '-->', c)
17+
else:
18+
move(n-1, a, c, b)
19+
move(1, a, b, c)
20+
move(n-1, b, a, c)
21+
22+
move(2, 'A', 'B', 'C')

0 commit comments

Comments
 (0)