Day17 参加职训(机器学习与资料分析工程师培训班),Python程式设计

练习使用selenium来登入FB

from selenium import webdriverdriver = webdriver.Chrome()driver.get('https://www.facebook.com/')driver.find_element_by_id('email').send_keys('E-mail')driver.find_element_by_id('pass').send_keys('密码')driver.find_element_by_name('login').click()#driver.close()

使用tkinter模组製作GUI画面

import tkinter as tkbase = tk.Tk()Label01 = tk.Label(base, text = 'Red', bg = 'red', font = ('Arial', 12), width = 20).pack()Label02 = tk.Label(base, text = 'Green', bg = 'green', width = 20, height = 3).pack()Label03 = tk.Label(base, text = 'Blue', fg = 'white', bg = 'blue', width = 20).pack()base.mainloop()

http://img2.58codes.com/2024/20139039QkTIczrWl1.png

base = tk.Tk()textvar = tk.StringVar() # 设定一个tk的字串变数Label01 = tk.Label(base, textvariable = textvar, fg = 'white', bg = 'red', font = ('Arial', 12), width = 20, height = 2).pack()textvar.set('Hello World !!!')base.mainloop()

http://img2.58codes.com/2024/2013903968LgTJQ3JR.png

# Radiobuttonimport tkinter as tkdef select():    selection = 'Radio button ' + str(My_value.get()) + ' is chosen'    My_String.set(selection)base = tk.Tk()My_String = tk.StringVar()My_value = tk.IntVar()Button01 = tk.Radiobutton(base, text = 'Option01', variable = My_value, value = 1, command = select).pack()Button02 = tk.Radiobutton(base, text = 'Option02', variable = My_value, value = 2, command = select).pack()Button03 = tk.Radiobutton(base, text = 'Option03', variable = My_value, value = 3, command = select).pack()Label01 = tk.Label(base, textvar = My_String).pack()base.mainloop()

http://img2.58codes.com/2024/20139039KLdUigEdRw.png

# Checkbuttondef leave():    base.destroy()base = tk.Tk()Choice01 = tk.IntVar()Choice02 = tk.IntVar()Choice03 = tk.IntVar()CB01 = tk.Checkbutton(base, text = 'Math', variable = Choice01, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)CB02 = tk.Checkbutton(base, text = 'Chinese', variable = Choice02, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)CB03 = tk.Checkbutton(base, text = 'English', variable = Choice03, offvalue = 0,onvalue = 1, ).pack(anchor = tk.W)Button01 = tk.Button(base, text = 'Submit', command=leave).pack()base.mainloop()

http://img2.58codes.com/2024/201390397F3XMGJoJB.png


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章