import network,time
wlan = network.WLAN(network.STA_IF) # 创建一个WLAN实例 create station interface
wlan.active(True) # 激活实例 activate the interface
wlan.scan() # 扫描WIFI scan for access points
wlan.isconnected() # 判断WIFI连接否, 返回布尔值 check if the station is connected to an AP
wlan.connect('HUAWEI-WULIAN', 'onlychina') # 连接WIFI connect to an AP
wlan.config('mac') # 获取实例的MAC地址 get the interface's MAC address
wlan.ifconfig() # 获取实例的网络信息 get the interface's IP/netmask/gw/DNS addresses
ap = network.WLAN(network.AP_IF) # 创建一个AP实例 create access-point interface
ap.active(True) # 激活实例 activate the interface
ap.config(max_clients=10) # 设定多少个客户端可以连接它 set how many clients can connect to the network
ap.config(essid='ESP-AP') # 配置实例的essid参数 set the ESSID of the access point
time.sleep(3)
import webrepl
webrepl.start()
点击菜单“Object(对象)”,然后单击选项“Fill and Stroke(填充和描边)”(键盘快捷键为Ctrl + Shift + F)。首先,我们需要禁用描边,所以选择“Stroke paint(描边颜料)”选项卡并选择“No paint(无颜料)”(大X)。接下来,我们要更改矩形的颜色以匹配分线板的颜色。该板的颜色为深灰色,我们可以在“Fill(填充)”选项卡中进行设置,我选择颜色#141414。
现在我们需要确定矩形的尺寸。选择矩形,并在顶部栏中更改其宽度和高度以匹配元件的外部尺寸。ML8511分线板为20.0 mm x 20.0 mm,因此我输入这些尺寸。接下来,删除正方形周围的所有空白画布是一个不错的主意,这样我们就不必担心多余的画布。再次打开“Document Properties(文档属性)”窗口,并在第一个选项卡“Page(页面)”中按下“Resize page to drawing or selection(根据图纸或选择调整页面大小)”按钮。现在这个页面跟这个正方形一样大! 图7. 调整页面大小以匹配正方形电路板
该正方形将成为所有部件的基板,就像真实的PCB一样。首先,我们必须添加两个安装孔。创建两个直径与实际安装孔相同的白色圆圈。要创建一个圆,请选择Circle/Ellipse(圆/椭圆工具)并创建一个椭圆。然后,就像我们处理矩形一样,将其颜色改为白色(以便我们可以在电路板的深灰色背景下看到它),并设置其宽度和高度(在本例中为3.3毫米 x 3.3毫米)。将两个圆圈放置在要创建安装孔的位置。 图8. 准备安装孔
现在我们来处理非常酷的矢量内容——选择页面上的所有对象(灰色方块和两个白色圆圈),然后进入菜单“Path(路径)”。点击“Object to Path(对象转路径)”选项。现在,不再有不同类型的对象(矩形和圆形)了,所有对象都具有相同的类型:路径。路径也是对象,能够使用原始对象无法实现的方法进行操作。比如,您可以将一个矩形转换一个路径并在边上添加两个点,将其变成一个六边形!您还可以对路径执行数学运算;您可以将两条路径合并成一条路径。我们将使用其中一种方法在灰色方块中“钻孔”。选择所有对象,返回“Path(路径)”菜单,单击选项“Exclusion(排除)”。眨眼间,白色圆圈现在变成了两个孔! 图9. 创建安装孔
要将一个对象移至另外一个对象的中心,我们应使用另一个功能:“Object(对象)”菜单中的“Align and Distribute(对齐和分配)”(Ctrl + Shift + A)。选择第一个对象(比如浅灰色方块),然后选择第二个对象(小深灰色圆圈)。现在,在“Align and Distribute(对齐和分配)”窗口中,将“Relative to(相对于)”设置为“First selected(首先选中)”,然后单击“Center on vertical axis(垂直轴居中对齐)”和“Center on horizontal axis(水平轴居中对齐)”。这会将小圆圈恰好移至浅灰色方块的中心。 图11. 连接器针脚的顶视图
之前的所有工作都是为这一步做准备!Fritzing不允许直接创建新元件,所以唯一的方法就是编辑现有元件。比如,在面包板视图中,添加一些元件:我们之前使用的加速度计。右键单击该元件并选择选“Edit (new parts editor)(编辑(新元件编辑器))”。系统会在新窗口中打开元件编辑器。 图30. Fritzing元件编辑器
点击“File(文件)”菜单中的“Save as new part(另存为新元件)”,以保存元件。系统会提示您输入文件名前缀,但这不是必需的,因此只需保留默认值即可。任务完成!您现在可以关闭元件编辑器,并打开Fritzing主窗口。您的新元件将位于“My Parts(我的元件)”箱中,从现在开始,您可以像使用其他Fritzing元件一样使用它!
要比较不同的图层和组,你可以打开Fritzing BreadboardViewGraphic_Template.svg文件,该文件位于先前下载的Fritzing Fonts and Template文件夹中。你还可以从SparkFun Fritzing Parts Github仓库打开示例SparkFun T5403晴雨表分线板SVG模板文件。
Naming your connectors will be a huge time saver. For the SparkFun T5403 Barometer Breakout example, under the copper group, each connector is named connector#pad.
The ESP32-C3 has 2 hardware UARTs: UART0, UART1. They each have default GPIO assigned to them, however depending on your ESP32-C3 variant and board, these pins may conflict with embedded flash, onboard PSRAM or peripherals.
Any GPIO can be used for hardware UARTs using the GPIO matrix, so to avoid conflicts simply provide tx and rx pins when constructing. The default pins listed below.
UART0
UART1
tx
21
任意IO
rx
20
任意IO
PWM (脉宽调制)¶
There’s a higher-level abstraction machine.Signal which can be used to invert a pin. Useful for illuminating active-low LEDs using on() or value(1).
PWM 能在所有可输出引脚上实现。基频的范围可以从 40Hz 到 40MHz 但需要权衡: 随着基频的 增加 占空分辨率 下降. 详情请参阅: LED Control . 现在占空比范围为 0-1023
There are two hardware I2C peripherals with identifiers 0 and 1. Any available output-capable pins can be used for SCL and SDA but the defaults are given below.
I2C(0)
I2C(1)
scl
18
25
sda
19
26
The driver is accessed via the machine.I2C class and has the same methods as software I2C above:
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')
#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)
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()