自动生成域名

最近想注册个好一点的域名,而且长度不能超过5个字母的短域名,否则不容易记,另外因.com的权威性,当然选择后缀com,但注册时发现好域名都已经被注册了,自己一个一个试挺麻烦的,写了一个python程序,很容易就随机生成了短域名,一般域名查询网站都不允许一次查询超过50个域名,那每次生成50个即可,上代码:

list1=[]
for i in range(97,123):
    list1.append(chr(i))
import random
for i in range(50):
	str1=''.join(random.choices(list1,k=5))
	print(f'{str1}')

改进版本

list1=[]
s=''
j=0
t=2
for i in range(97,123):
    list1.append(chr(i))
import random
for i in range(26**t):
    str1='tip'+''.join(random.choices(list1,k=t))
    s=str1+','+s
a = s.split(',')
b = list(set(a))
for str2 in b:
    j=j+1
    if j % 50 ==0:
        print('\n\n')
    if str2!='':
        print(str2)

优化版本(非随机抽取,这样可以防止部分域名丢失)

baseword=[];domain='';spliti=0
t=26;k=0
keystart='zero'
keyend=''
for i in range(97,123):
    baseword.append(chr(i))
for i in range(t):
    if k>0:
        for j in range(k):
            domain=domain+keystart+baseword[i]+baseword[j]+keyend+','
    elif k==0:
        domain=domain+keystart+baseword[i]+keyend+','
domainlist = domain.split(',')
print(len(domainlist))
for regdomain in domainlist:
    spliti=spliti+1
    if spliti % 50 ==0:
        print('')
    if regdomain!='':
        print(regdomain)

递进版本

import itertools
spliti=0
baseword=[]
domainlist=''
abc=0
keystart='pid'
for i in range(97,123):
    baseword.append(chr(i))
for item in itertools.product(keystart,baseword,baseword,baseword):
    spliti=spliti+1
    if spliti % 1000 ==0:
        abc=abc+1
    if item!='':
        with open(str(abc)+'.txt',mode='a',encoding='utf-8') as f:
            f.write(domainlist.join(item)+'\n')

更迭版本

import itertools
spliti=0
baseword=[]
domainlist=''
abc=0
keystart='way'
for i in range(97,123):
    baseword.append(chr(i))
for item in itertools.product(keystart[0],keystart[1],keystart[2],baseword,baseword):
    spliti=spliti+1
    if spliti % 1000 ==0:
        print('')
        abc=abc+1
    if item!='':
#        print(domainlist.join(item))
        with open(str(abc)+'.txt',mode='a',encoding='utf-8') as f:
            f.write(domainlist.join(item)+'\n')

跃升版本

from itertools import product
spliti=0
domainlist=''
filename=0
li=[]
'''
s=list(keystart)
print(len(keystart))
s.extend(keystart)
s0=(','.join(keystart))
'''
def getdomainword(key,nums,flag):
    baseword=[]
    a=list(key)
    for i in range(97,123):
        baseword.append(chr(i))
    if flag==0:
        for i in range(nums):
            a.append(baseword)
    elif flag==1:
        for i in range(nums):
            a.insert(i,baseword)
    return a
print('请输入域名关键词: ',end='')
domain=input()
print('请输入位数(穷举英文位数): ',end='')
numbs=int(input())
print('请输入关键词 "'+domain+'" 在域名中的位置("0"在头部,"1"在尾部): ',end='')
flag=int(input())
li=getdomainword(domain,numbs,flag)
for item in product(*li):
    spliti=spliti+1
    if spliti % 1000 ==0:
        print('')
        filename=filename+1
    if item!='':
        print(domainlist.join(item))
#        with open(str(filename)+'.txt',mode='a',encoding='utf-8') as f:
#            f.write(domainlist.join(item)+'\n')

下面是各个系统的可执行文件,直接下载解压执行即可

Mac OS

Windows(64Bit)

Linux(32Bit)

从英文名著中获取英文单词

#keyword.txt为英文名著txt文件
import re
#a='Beautiful, is; better*than\nugly'
file=open('keyword.txt','r')
a=file.read()
# 四个分隔符为:,  ;  *  \n
x= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'',a)
lista=list(set(x))
lista.sort(key=len)
for t in sorted(lista,key = len):
    print(t)
file.close()  #文件打开,使用完毕后需要关闭

改进版本

import re
file=open('69004.txt','r')
a=file.read()
listb = []
listc = []
# 分隔符为:,  ;  *  \n
x= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$',a)
file.close()  #文件打开,使用完毕后需要关闭
lista=list(set(x))
lista.sort(key=len)
lista.sort(key=str.lower)
for t in lista:
    listb.append(t.lower())
listc=sorted(set(listb))
for t in sorted(listc,key=len):
    print(t)

改进版本(去重/去数字/叠加关键词)

import re
file=open('69004.txt','r')
txt=file.read()
worda = []
wordb = []
word = []
# 分隔符为:,  ;  *  \n
pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]',txt)
file.close()  #文件打开,使用完毕后需要关闭
for t in pre_word:
    worda.append(t.lower())
wordb=sorted(set(worda))
for t in sorted(wordb,key=len):
    if not t.isdigit():   #判断非数字
        word.append(t)

for i in word:
    if len(i)<=3:
        print("nest"+i)

英文经典资料来源

https://gutenberg.org/

import re
file=open('words.txt','r')
txt=file.read()
worda = []
wordb = []
word = []
# 分隔符为:,  ;  *  \n
pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[',txt)
file.close()  #文件打开,使用完毕后需要关闭
for t in pre_word:
    worda.append(t.lower())
wordb=sorted(set(worda))
for t in sorted(wordb,key=len):
    if not t.isdigit():   #判断非数字
        word.append(t)

for i in word:
    if len(i)<=3:
        print("mix"+i)

读取链接文件

import re
from lxml import etree

html = etree.parse('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt',etree.HTMLParser())
result = etree.tostring(html)
#print(result.decode('utf-8'))
#file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
#txt=file.read()
txt = result.decode('utf-8')
worda = []
wordb = []
word = []
# 分隔符为:,  ;  *  \n
pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[',txt)
for t in pre_word:
    worda.append(t.lower())
wordb=sorted(set(worda))
for t in sorted(wordb,key=len):
    if not t.isdigit():   #判断非数字
        word.append(t)

for i in word:
    if len(i)<=3:
        print("mix"+i)

升级版本

import re
from lxml import etree

html = etree.parse('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt',etree.HTMLParser())
result = etree.tostring(html)
#print(result.decode('utf-8'))
#file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
#txt=file.read()
txt = result.decode('utf-8')
worda = []
wordb = []
word = []
# 分隔符为:,  ;  *  \n
pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt)
for t in pre_word:
    worda.append(t.lower())
wordb=sorted(set(worda))
for t in sorted(wordb,key=len):
    if not t.isdigit():   #判断非数字
        word.append(t)
print("请输入域名关键词:")
keyword=input()
print("输入关键词在组合单词的位置:1=关键字前置,2=关键字后置")
flag=input()

for i in word:
    if len(i)<=3:
        if flag=='1':
            print(keyword+i)
        elif flag=='2':
            print(i+keyword)
        else:
            pass

图形版本

from tkinter import *

def Mysel():
      dic = {0:'1',1:'2'}
      s = dic.get(var.get())
      return s

def run1():
    a = inp1.get()
    b = Mysel()

    import re
    from lxml import etree

    html = etree.parse('http://andoq.com/words.txt',etree.HTMLParser())
    result = etree.tostring(html)
    #print(result.decode('utf-8'))
    #file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
    #txt=file.read()
    txt1 = result.decode('utf-8')
    worda = []
    wordb = []
    word = []
    # 分隔符为:,  ;  *  \n
    pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt1)
    for t in pre_word:
        worda.append(t.lower())
    wordb=sorted(set(worda))
    for t in sorted(wordb,key=len):
        if not t.isdigit():   #判断非数字
            word.append(t)
            
    for i in word:
        if len(i)<=3:
            if b=='1':
                txt.insert(END, a+i+'\n')   # 追加显示运算结果
            elif b=='2':
                txt.insert(END, i+a+'\n')   # 追加显示运算结果
            else:
                pass

 
root = Tk()
root.geometry('400x800')
root.title('域名生成器')
 
var = IntVar()
rd1 = Radiobutton(root,text="前置",variable=var,value=0,command=Mysel)
rd1.place(relx=0.6, rely=0.02, relwidth=0.3, relheight=0.04)
 
rd2 = Radiobutton(root,text="后置",variable=var,value=1,command=Mysel)
rd2.place(relx=0.6, rely=0.06, relwidth=0.3, relheight=0.04)

lb1 = Label(root, text='请输入关键词')
lb1.place(relx=0.1, rely=0.01, relwidth=0.2, relheight=0.05)
inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.05, relwidth=0.3, relheight=0.04)
#inp2 = Entry(root)
#inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
 
# 方法-直接调用 run1()
btn1 = Button(root, text='生成域名', command=run1)
btn1.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.04)

 
# 在窗体垂直自上而下位置60%处起,布局相对窗体高度40%高的文本框
txt = Text(root)
txt.place(rely=0.15, relheight=0.85)
 
root.mainloop()
from tkinter import *

def Mysel():
      dic = {0:'1',1:'2'}
      s = dic.get(var.get())
      return s

def run1():
    a = inp1.get()
    b = Mysel()

    import re
    from lxml import etree

    html = etree.parse('http://andoq.com/words.txt',etree.HTMLParser())
    result = etree.tostring(html)
    #print(result.decode('utf-8'))
    #file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
    #txt=file.read()
    txt1 = result.decode('utf-8')
    worda = []
    wordb = []
    word = []
    # 分隔符为:,  ;  *  \n
    pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt1)
    for t in pre_word:
        worda.append(t.lower())
    wordb=sorted(set(worda))
    for t in sorted(wordb,key=len):
        if not t.isdigit():   #判断非数字
            word.append(t)
            
    for i in word:
        if len(i)<=3:
            if b=='1':
                txt.insert(END, a+i+'\n')   # 追加显示运算结果
            elif b=='2':
                txt.insert(END, i+a+'\n')   # 追加显示运算结果
            else:
                pass

 
root = Tk()
root.geometry('400x800')
root.resizable(0,0)
root.title('域名生成器')
 
var = IntVar()
rd1 = Radiobutton(root,text="前置",variable=var,value=0,command=Mysel)
rd1.place(relx=0.6, rely=0.02, relwidth=0.3, relheight=0.04)
 
rd2 = Radiobutton(root,text="后置",variable=var,value=1,command=Mysel)
rd2.place(relx=0.6, rely=0.06, relwidth=0.3, relheight=0.04)

lb1 = Label(root, text='请输入关键词')
lb1.place(relx=0.1, rely=0.01, relwidth=0.2, relheight=0.05)
inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.05, relwidth=0.3, relheight=0.04)
#inp2 = Entry(root)
#inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
 
# 方法-直接调用 run1()
btn1 = Button(root, text='生成域名', command=run1)
btn1.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.04)

 
# 在窗体垂直自上而下位置60%处起,布局相对窗体高度40%高的文本框
txt = Text(root)
txt.config(bg='#aad5df')
txt.place(rely=0.15, relheight=0.85)
 
root.mainloop()
from tkinter import *
import tkinter
from tkinter import ttk
num='1'
def Mysel():
      dic = {0:'1',1:'2'}
      s = dic.get(var.get())
      return s

def choose(event):
    global num
    # 选中事件
    num=format(combobox.get())


def run1():
    global num
    a = inp1.get()
    b = Mysel()

    import re
    from lxml import etree

    html = etree.parse('http://www.mixdiy.com/wp-content/uploads/2022/09/words.txt',etree.HTMLParser())
    result = etree.tostring(html)
    #print(result.decode('utf-8'))
    #file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
    #txt=file.read()
    txt1 = result.decode('utf-8')
    worda = []
    wordb = []
    word = []
    # 分隔符为:,  ;  *  \n
    pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt1)
    for t in pre_word:
        worda.append(t.lower())
    wordb=sorted(set(worda))
    for t in sorted(wordb,key=len):
        if not t.isdigit():   #判断非数字
            word.append(t)
    txt.delete('1.0','end')
    for i in word:
        if len(i)<=int(num):
            if b=='1':
                txt.insert(END, a+i+'\n')   # 追加显示运算结果
            elif b=='2':
                txt.insert(END, i+a+'\n')   # 追加显示运算结果
            else:
                pass

 
root = Tk()
root.geometry('400x800+120+120')
root.resizable(0,0)
root.title('域名生成器')
scroll = tkinter.Scrollbar()



value = StringVar()
value.set("1")
values = ["0", "1", "2", "3", "4", "5", "6"]
combobox = ttk.Combobox(
    master=root, # 父容器
    height=50, # 高度,下拉显示的条目数量
    width=20, # 宽度
    state="readonly", # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
    cursor="arrow", # 鼠标移动时样式 arrow, circle, cross, plus...
    font=("", 10), # 字体
    textvariable=value, # 通过StringVar设置可改变的值
    values=values, # 设置下拉框的选项
    )
print(combobox.keys()) # 可以5查看支持的参数
combobox.place(relx=0.55, rely=0.03, relwidth=0.15, relheight=0.02)
combobox.bind("<<ComboboxSelected>>", choose)


var = IntVar()
rd1 = Radiobutton(root,text="前置",variable=var,value=0,command=Mysel)
rd1.place(relx=0.75, rely=0.02, relwidth=0.3, relheight=0.04)
 
rd2 = Radiobutton(root,text="后置",variable=var,value=1,command=Mysel)
rd2.place(relx=0.75, rely=0.06, relwidth=0.3, relheight=0.04)

lb1 = Label(root, text='请输入关键词')
lb1.place(relx=0.1, rely=0.01, relwidth=0.2, relheight=0.05)
inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.05, relwidth=0.3, relheight=0.04)
#inp2 = Entry(root)
#inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
 
# 方法-直接调用 run1()
btn1 = Button(root, text='生成域名', command=run1)
btn1.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.04)

scroll.place(relx=0.95, rely=0.15, relheight=0.85, relwidth=0.05) 
# 在窗体垂直自上而下位置60%处起,布局相对窗体高度40%高的文本框
txt = Text(root)
scroll.config(command=txt.yview)
txt.config(bg='#aad5df')
txt.config(yscrollcommand=scroll.set)
txt.place(relx=0, rely=0.15, relheight=0.85 ,relwidth=0.95)
 
root.mainloop()
from tkinter import *
import tkinter
from tkinter import ttk
num='1'
def Mysel():
      dic = {0:'1',1:'2'}
      s = dic.get(var.get())
      return s

def choose(event):
    global num
    # 选中事件
    num=format(combobox.get())

def run1():
    global num
    a = inp1.get()
    b = Mysel()

    import re
    from lxml import etree

    html = etree.parse('http://www.mixdiy.com/wp-content/uploads/2022/09/words.txt',etree.HTMLParser())
    result = etree.tostring(html)
    #print(result.decode('utf-8'))
    #file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
    #txt=file.read()
    txt1 = result.decode('utf-8')
    worda = []
    wordb = []
    word = []
    # 分隔符为:,  ;  *  \n
    pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt1)
    for t in pre_word:
        worda.append(t.lower())
    wordb=sorted(set(worda))
    for t in sorted(wordb,key=len):
        if not t.isdigit():   #判断非数字
            word.append(t)
    txt.delete('1.0','end')
    for i in word:
        if len(i)<=int(num):
            if b=='1':
                txt.insert(END, a+i+'\n')   # 追加显示运算结果
            elif b=='2':
                txt.insert(END, i+a+'\n')   # 追加显示运算结果
            else:
                pass

root = Tk()
root.geometry('400x800+120+120')
root.resizable(0,0)
root.title('域名生成器')
scroll = tkinter.Scrollbar()

value = StringVar()
value.set("1")
values = ["0", "1", "2", "3", "4", "5", "6"]
combobox = ttk.Combobox(
    master=root, # 父容器
    height=50, # 高度,下拉显示的条目数量
    width=20, # 宽度
    state="readonly", # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
    cursor="arrow", # 鼠标移动时样式 arrow, circle, cross, plus...
    font=("", 12), # 字体
    textvariable=value, # 通过StringVar设置可改变的值
    values=values, # 设置下拉框的选项
    )
#print(combobox.keys()) # 可以5查看支持的参数
combobox.place(relx=0.57, rely=0.052, relwidth=0.15, relheight=0.025)
combobox.bind("<<ComboboxSelected>>", choose)

var = IntVar()
rd1 = Radiobutton(root,text="前置",variable=var,value=0,command=Mysel)
rd1.place(relx=0.75, rely=0.02, relwidth=0.3, relheight=0.04)
 
rd2 = Radiobutton(root,text="后置",variable=var,value=1,command=Mysel)
rd2.place(relx=0.75, rely=0.06, relwidth=0.3, relheight=0.04)

lb1 = Label(root, text='域名主关键词')
lb1.place(relx=0.1, rely=0.01, relwidth=0.2, relheight=0.05)

lb1 = Label(root, text='匹配单词字母个数')
lb1.place(relx=0.4, rely=0.02, relwidth=0.4, relheight=0.03)

inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.05, relwidth=0.3, relheight=0.03)
#inp2 = Entry(root)
#inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
 
# 方法-直接调用 run1()
btn1 = Button(root, text='生成域名', command=run1)
btn1.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.04)

scroll.place(relx=0.95, rely=0.15, relheight=0.85, relwidth=0.05) 
# 在窗体垂直自上而下位置60%处起,布局相对窗体高度40%高的文本框
txt = Text(root)
scroll.config(command=txt.yview)
txt.config(bg='#aad5df')
txt.config(yscrollcommand=scroll.set)
txt.place(relx=0, rely=0.15, relheight=0.85 ,relwidth=0.95)
 
root.mainloop()
from tkinter import *
import tkinter
from tkinter import ttk
num='1'
domaintogal=0
def Mysel():
      dic = {0:'1',1:'2'}
      s = dic.get(var.get())
      return s

def choose(event):
    global num
    # 选中事件
    num=format(combobox.get())

def run1():
    global num,domaintogal
    a = inp1.get()
    b = Mysel()
    j = 0
    import re
    from lxml import etree

    html = etree.parse('http://www.mixdiy.com/wp-content/uploads/2022/09/words.txt',etree.HTMLParser())
    result = etree.tostring(html)
    #print(result.decode('utf-8'))
    #file=open('http://xn--ogtw0vdov42a.xn--fiqs8s/words.txt','r')
    #txt=file.read()
    txt1 = result.decode('utf-8')
    worda = []
    wordb = []
    word = []
    # 分隔符为:,  ;  *  \n
    pre_word= re.split(' |,|; |\!|\?|\_|\:|\-|\.|\*|\n|\'|\"|\‘|\/|\”|\“|\%|\’|\(|\)|\$|\&|\]|\—|\;|\#|\[|\<|\>',txt1)
    for t in pre_word:
        worda.append(t.lower())
    wordb=sorted(set(worda))
    for t in sorted(wordb,key=len):
        if not t.isdigit():   #判断非数字
            word.append(t)
    txt.delete('1.0','end')
    for i in word:
        j=j+1
        if len(i)<=int(num):
            if j % 1000 ==0:
                txt.insert(END, '-----------------------------------\n')
            if b=='1':
                txt.insert(END, a+i+'\n')   # 追加显示运算结果
            elif b=='2':
                txt.insert(END, i+a+'\n')   # 追加显示运算结果
            else:
                pass
    domaintogal=int(txt.index('end-1c').split('.')[0])-1
    lb3 = Label(root, text='生成的域名总数: '+str(domaintogal))
    print(domaintogal)
    lb3.place(relx=0.4, rely=0.1, relwidth=0.4, relheight=0.03)
    
root = Tk()
root.geometry('400x800+120+120')
root.resizable(0,0)
root.title('域名生成器')
scroll = tkinter.Scrollbar()

value = StringVar()
value.set("1")
values = ["0", "1", "2", "3", "4", "5", "6", "7", "8"]
combobox = ttk.Combobox(
    master=root, # 父容器
    height=50, # 高度,下拉显示的条目数量
    width=20, # 宽度
    state="readonly", # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled
    cursor="arrow", # 鼠标移动时样式 arrow, circle, cross, plus...
    font=("", 12), # 字体
    textvariable=value, # 通过StringVar设置可改变的值
    values=values, # 设置下拉框的选项
    )
#print(combobox.keys()) # 可以5查看支持的参数
combobox.place(relx=0.57, rely=0.052, relwidth=0.15, relheight=0.025)
combobox.bind("<<ComboboxSelected>>", choose)

var = IntVar()
rd1 = Radiobutton(root,text="前置",variable=var,value=0,command=Mysel)
rd1.place(relx=0.75, rely=0.02, relwidth=0.3, relheight=0.04)
 
rd2 = Radiobutton(root,text="后置",variable=var,value=1,command=Mysel)
rd2.place(relx=0.75, rely=0.06, relwidth=0.3, relheight=0.04)

lb1 = Label(root, text='域名主关键词')
lb1.place(relx=0.1, rely=0.01, relwidth=0.2, relheight=0.05)

lb2 = Label(root, text='匹配单词字母个数')
lb2.place(relx=0.4, rely=0.02, relwidth=0.4, relheight=0.03)

lb3 = Label(root, text='生成的域名总数')
lb3.place(relx=0.4, rely=0.1, relwidth=0.4, relheight=0.03)

inp1 = Entry(root)
inp1.place(relx=0.1, rely=0.05, relwidth=0.3, relheight=0.03)
#inp2 = Entry(root)
#inp2.place(relx=0.6, rely=0.2, relwidth=0.3, relheight=0.1)
 
# 方法-直接调用 run1()
btn1 = Button(root, text='生成域名', command=run1)
btn1.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.03)

scroll.place(relx=0.95, rely=0.15, relheight=0.85, relwidth=0.05) 
# 在窗体垂直自上而下位置60%处起,布局相对窗体高度40%高的文本框
txt = Text(root)
scroll.config(command=txt.yview)
txt.config(bg='black',selectbackground='red',foreground = 'white')
txt.config(yscrollcommand=scroll.set)
txt.place(relx=0, rely=0.15, relheight=0.85 ,relwidth=0.95)

root.mainloop()