用户:
mummummuuu查看:0 回复:0 评论:0 创建时间:2021-10-24T20:58:16
想知道你和ta的缘分吗?快来试试吧(无科学依据,请勿轻信)
最高124,最低0
姓名缩写是拼音首字母,如小明:xm,小红:xh
声调是第二个字的声调:1/2/3/4
from tkinter import *
def func():
global var
def db(a, b):
s = ''
for i in range(len(a)):
if a[i] == b[i]:
s += '1'
else:
s += '0'
return s
def fl(s):
l = []
word = ''
for i in range(1, len(s)+1):
word += s[i-1]
if i % 5 == 0:
l.append(word)
word = ''
return l
d = {'a': '00001', 'b': '00010', 'c': '00011', 'd': '00100',
'e': '00101', 'f': '00110', 'g': '00111', 'h': '01000',
'i': '01001', 'j': '01010', 'k': '01011', 'l': '01100',
'm': '01101', 'n': '01110', 'o': '01111', 'p': '10000',
'q': '10001', 'r': '10010', 's': '10011', 't': '10100',
'u': '10101', 'v': '10110', 'w': '10111', 'x': '11000',
'y': '11001', 'z': '11010', '0': '11011', '1': '11100',
'2': '11101', '3': '11110', '4': '11111'}
dl = ['00000', '00001', '00010', '00011', '00100', '00101',
'00110', '00111', '01000', '01001', '01010',
'01011', '01100', '01101', '01110', '01111',
'10000', '10001', '10010', '10011', '10100',
'10101', '10110', '10111', '11000', '11001',
'11010', '11011', '11100', '11101', '11110',
'11111']
p, sp = namesx1.get(), namesd1.get()
spd=''.join([d[i] for i in sp])
pd = ''.join([d[i] for i in p])
a, sa = namesx2.get(), namesd2.get()
sad = ''.join([d[i] for i in sa])
ad = ''.join([d[i] for i in a])
if len(p) == 2:
p = p + '.'
if pd[-1] == '0':
pd = pd+'10101'
else:
pd = pd+'01010'
else:
p = p[:3]
pd = pd[:15]
if len(a) == 2:
a = a + '.'
if ad[-1] == '0':
ad = ad+'10101'
else:
ad = ad+'01010'
else:
a = a[:3]
ad = ad[:15]
pd=pd+spd
ad=ad+sad
#print(pd)
#print(ad)
dbs = db(pd, ad)
#print(dbs)
l = fl(dbs)
#print(l)
d = 0
for i in l:
d += dl.index(i)
var.set(d)
win=Tk()
var=StringVar()
win.geometry('600x400')
win.title('缘分')
txtnm1=Label(win,text='姓名缩写1:')
txtnm2=Label(win,text='姓名缩写2:')
namesx1=Entry(win)
namesx2=Entry(win)
txtsd1=Label(win,text='声调1:')
txtsd2=Label(win,text='声调2:')
namesd1=Entry(win)
namesd2=Entry(win)
ok_butt=Button(win,text='确认',command=func)
show_lab=Label(win,textvariable=var)
txtnm1.pack()
namesx1.pack()
txtsd1.pack()
namesd1.pack()
txtnm2.pack()
namesx2.pack()
txtsd2.pack()
namesd2.pack()
ok_butt.pack()
show_lab.pack()
win.mainloop()