如何在Tkinter中添加图像?
这给了我一个语法错误:
root = tk.Tk()
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
root.mainloop()
Run Code Online (Sandbox Code Playgroud) 我正在尝试解析需要登录的网页的 HTML。我可以使用以下脚本获取网页的 HTML:
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
import re
webpage = urlopen ('https://www.example.com')
soup = BeautifulSoup (webpage)
print soup
#This would print the source of example.com
Run Code Online (Sandbox Code Playgroud)
但事实证明,尝试获取我登录的网页的源代码更加困难。我尝试将 ('https://www.example.com') 替换为 ('https://user:pass@example.com'),但收到无效 URL 错误。
有人知道我该怎么做吗?提前致谢。
我希望使用itertools从字母表中的每个字母获得所有3个字母的排列.这回来是空白的:
import itertools
def permutations(ABCDEFGHIJKLMNOPQRSTUVWXYZ, r=3):
pool = tuple(iterable)
n = len(pool)
r = n if r is None else r
for indices in product(range(n), repeat=r):
if len(set(indices)) == r:
yield tuple(pool[i] for i in indices)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?