有的时候自己需要的代码前面有一些奇怪的行标,这样会导致cv战士无法快速运行想要的代码
下面就是去除每一行前面的数字行标的python实现
替换s为需要的代码即可(按照自己需要删去的数量自行调整)
s=""" 1 def Login():
2 global Flag
3 try:
4 bot.Login(['-q',v1.get()])
5 tkinter.messagebox.showinfo(message="登陆成功")
6 Flag=1
7 except Exception as e:
8 tkinter.messagebox.showerror(message=str(e))
9 def Send():
10 global Flag
11 if Flag==0:
12 tkinter.messagebox.showwarning(message='您还没有登陆,不能发送消息!')
13 return ''
14 content= T1.get(1.0, tkinter.END)
15 if vOption.get() == 1:
16 Friends=bot.List('buddy')
17 elif vOption.get() == 2:
18 Friends = bot.List('group')
19 for friend in Friends:
20 if v2.get() in friend.name:
21 try:
22 bot.SendTo(friend, content)
23 except Exception as e:
24 tkinter.messagebox.showerror(message=str(e))
25 tkinter.messagebox.showinfo(message="发送完毕")
26 if __name__ == '__main__':
27 root = tkinter.Tk()
28 L1 = tkinter.Label(root, text='QQ账号')
29 L1.place(x=10,y=10,height=30)
30 v1 = tkinter.StringVar()
31 E1 = tkinter.Entry(root, textvariable=v1)
32 E1.place(x=60,y=10,width=120,height=30)
33 B1 = tkinter.Button(root, text='登陆', command=Login)
34 B1.place(x=190,y=10,width=50,height=30)
35 vOption = tkinter.IntVar(value=1)
36 R1 = tkinter.Radiobutton(root, text='发给所有好友', variable=vOption, value=1)
37 R1.place(x=10,y=50)
38 R2 = tkinter.Radiobutton(root, text='发给所有群', variable=vOption, value=2)
39 R2.place(x=10,y=70)
40 L2 = tkinter.Label(root, text='名称包含')
41 L2.place(x=130,y=60)
42 v2 = tkinter.StringVar()
43 E2 = tkinter.Entry(root, textvariable=v2)
44 E2.place(x=190,y=60,width=50)
45 T1 = tkinter.Text(root)
46 T1.place(x=10,y=110,width=230,height=100)
47 B1 = tkinter.Button(root, text='发送', command=Send)
48 B1.place(x=10, y=220, width=230, height=30)
49 Flag=0
50 root.resizable(False, False)
51 root.geometry('250x250+300+300')
52 root.mainloop()"""
str_list = s.split(sep='\n')
ha = ""
for i in str_list:
ha = ha + i[3:] + "\n"
#需要在i后面修改前面的需要删去的数量
print(ha)
输出结果:
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()
给自己的代码每一行前面加上行标_long_songs的博客-CSDN博客https://blog.csdn.net/long_songs/article/details/122741770
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/73575.html