有时候想和大家分享自己的思路但是不想让cv战士直接白嫖,就会想到给自己的代码前面加上行标,让其他人cv的慢一点
以下就是加密代码,将s里的代码换成自己的即可
s="""def Login():
global Flag
try:
bot.Login(['-q',v1.get()])
tkinter.messagebox.showinfo(message="登陆成功")
Flag=1
except Exception as e:
tkinter.messagebox.showerror(message=str(e))
def Send():
global Flag
if Flag==0:
tkinter.messagebox.showwarning(message='您还没有登陆,不能发送消息!')
return ''
content= T1.get(1.0, tkinter.END)
if vOption.get() == 1:
Friends=bot.List('buddy')
elif vOption.get() == 2:
Friends = bot.List('group')
for friend in Friends:
if v2.get() in friend.name:
try:
bot.SendTo(friend, content)
except Exception as e:
tkinter.messagebox.showerror(message=str(e))
tkinter.messagebox.showinfo(message="发送完毕")
if __name__ == '__main__':
root = tkinter.Tk()
L1 = tkinter.Label(root, text='QQ账号')
L1.place(x=10,y=10,height=30)
v1 = tkinter.StringVar()
E1 = tkinter.Entry(root, textvariable=v1)
E1.place(x=60,y=10,width=120,height=30)
B1 = tkinter.Button(root, text='登陆', command=Login)
B1.place(x=190,y=10,width=50,height=30)
vOption = tkinter.IntVar(value=1)
R1 = tkinter.Radiobutton(root, text='发给所有好友', variable=vOption, value=1)
R1.place(x=10,y=50)
R2 = tkinter.Radiobutton(root, text='发给所有群', variable=vOption, value=2)
R2.place(x=10,y=70)
L2 = tkinter.Label(root, text='名称包含')
L2.place(x=130,y=60)
v2 = tkinter.StringVar()
E2 = tkinter.Entry(root, textvariable=v2)
E2.place(x=190,y=60,width=50)
T1 = tkinter.Text(root)
T1.place(x=10,y=110,width=230,height=100)
B1 = tkinter.Button(root, text='发送', command=Send)
B1.place(x=10, y=220, width=230, height=30)
Flag=0
root.resizable(False, False)
root.geometry('250x250+300+300')
root.mainloop()
"""
str_list = s.split(sep='\n')
ha = ""
o = 0
for i in str_list:
ha = ha + '{0:>3}'.format(str(o)) + " " + i + "\n"
o = o + 1
print(ha)
输出结果:
0 def Login():
1 global Flag
2 try:
3 bot.Login(['-q',v1.get()])
4 tkinter.messagebox.showinfo(message="登陆成功")
5 Flag=1
6 except Exception as e:
7 tkinter.messagebox.showerror(message=str(e))
8 def Send():
9 global Flag
10 if Flag==0:
11 tkinter.messagebox.showwarning(message='您还没有登陆,不能发送消息!')
12 return ''
13 content= T1.get(1.0, tkinter.END)
14 if vOption.get() == 1:
15 Friends=bot.List('buddy')
16 elif vOption.get() == 2:
17 Friends = bot.List('group')
18 for friend in Friends:
19 if v2.get() in friend.name:
20 try:
21 bot.SendTo(friend, content)
22 except Exception as e:
23 tkinter.messagebox.showerror(message=str(e))
24 tkinter.messagebox.showinfo(message="发送完毕")
25 if __name__ == '__main__':
26 root = tkinter.Tk()
27 L1 = tkinter.Label(root, text='QQ账号')
28 L1.place(x=10,y=10,height=30)
29 v1 = tkinter.StringVar()
30 E1 = tkinter.Entry(root, textvariable=v1)
31 E1.place(x=60,y=10,width=120,height=30)
32 B1 = tkinter.Button(root, text='登陆', command=Login)
33 B1.place(x=190,y=10,width=50,height=30)
34 vOption = tkinter.IntVar(value=1)
35 R1 = tkinter.Radiobutton(root, text='发给所有好友', variable=vOption, value=1)
36 R1.place(x=10,y=50)
37 R2 = tkinter.Radiobutton(root, text='发给所有群', variable=vOption, value=2)
38 R2.place(x=10,y=70)
39 L2 = tkinter.Label(root, text='名称包含')
40 L2.place(x=130,y=60)
41 v2 = tkinter.StringVar()
42 E2 = tkinter.Entry(root, textvariable=v2)
43 E2.place(x=190,y=60,width=50)
44 T1 = tkinter.Text(root)
45 T1.place(x=10,y=110,width=230,height=100)
46 B1 = tkinter.Button(root, text='发送', command=Send)
47 B1.place(x=10, y=220, width=230, height=30)
48 Flag=0
49 root.resizable(False, False)
50 root.geometry('250x250+300+300')
51 root.mainloop()
去除每一行代码前的数字行标(字符串形式)_long_songs的博客-CSDN博客https://blog.csdn.net/long_songs/article/details/122741466