我有一个名为的脚本requests.py导入请求包.该脚本无法访问包中的属性,也无法导入它们.为什么这不起作用,我该如何解决?
以下代码提出了一个问题AttributeError.
import requests
res = requests.get('http://www.google.ca')
print(res)
Run Code Online (Sandbox Code Playgroud)
Traceback (most recent call last):
File "/Users/me/dev/rough/requests.py", line 1, in <module>
import requests
File "/Users/me/dev/rough/requests.py", line 3, in <module>
requests.get('http://www.google.ca')
AttributeError: module 'requests' has no attribute 'get'
Run Code Online (Sandbox Code Playgroud)
以下代码提出了一个问题ImportError.
from requests import get
res = get('http://www.google.ca')
print(res)
Run Code Online (Sandbox Code Playgroud)
Traceback (most recent call last):
File "requests.py", line 1, in <module>
from requests import get
File "/Users/me/dev/rough/requests.py", line 1, in <module>
from requests import get
ImportError: cannot import name 'get' …Run Code Online (Sandbox Code Playgroud) 我需要帮助,使用Python 3.5.2在Ubuntu 16.04.1上运行这个简单的Tkinter程序.
这是代码:
from tkinter import *
root = Tk()
mylabel = Label(root, text="Test")
mylabel.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
代码as-is给了我这个错误:
Traceback (most recent call last):
File "tkinter.py", line 8, in <module>
from tkinter import *
File "/home/dylan/Documents/proj/python/tkinter.py", line 10, in <module>
root = Tk()
NameError: name 'Tk' is not defined
Run Code Online (Sandbox Code Playgroud)
我注意到在浏览其他问题时,在制作Tkinter程序时会出现一些可能出错的热门内容.
python-tk和python3-tk软件包python3 tkinter.py.注意:将我的文件重命名为其他内容会tkinter.py导致一个奇怪的错误:
Traceback (most recent call last):
File "mytkinter.py", line 8, in <module>
from tkinter import *
ImportError: bad magic …Run Code Online (Sandbox Code Playgroud)