1
這是我的代碼,我不知道爲什麼我在終端上運行此程序時出現錯誤。這是我的python代碼python 3.5,我是新來curses模塊並無法處理此錯誤,請提前致謝TypeError:'_curses.curses窗口'對象不可調用
import urllib.request as ur
import time
import curses
def ini(i):
url = 'http://www.top4themes.com/data/out/134/6545537-superman-logo-wallpapers.jpg'
req = ur.urlopen(url)
count = 0
block_size= 1024
avg = 0
smin = []
value = False
t = []
while True:
start = time.time()
buff = req.read(block_size)
stop = time.time()
avg += len(buff)
if not buff:
break;
if (stop-start) < 0.2 :
block_size += 2048
elif (stop-start) > 0.2:
block_size -= 1024
count += 1
stdscr(1,0,"{}".format(block_size))
stdscr.refresh()
t.append(int(block_size))
if(block_size ==0):
block_size=max(t)
if __name__=="__main__":
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
try:
for i in range(10):
ini(i)
time.sleep(0.5)
finally:
curses.echo()
curses.nocbreak()
curses.endwin()
請將其完整的錯誤信息追溯到問題中,以便我們知道究竟是哪一行發生(以及在哪個調用序列期間)。 – GPhilo