Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ';超过最大递归深度';当循环urllib时_Python_Httprequest_Real Time_Urllib - Fatal编程技术网

Python ';超过最大递归深度';当循环urllib时

Python ';超过最大递归深度';当循环urllib时,python,httprequest,real-time,urllib,Python,Httprequest,Real Time,Urllib,你好,我有问题。我是python新手。我尝试使用urllib学习httprequest,以便从站点获取实时数据。所以我试着用最小延迟来循环。并有错误: Exception RuntimeError: 'maximum recursion depth exceeded' in <bound method _fileobject.__del__ of <socket._fileobject object at 0x01D650F0>> ignored 此代码的错误 Runt

你好,我有问题。我是python新手。我尝试使用urllib学习httprequest,以便从站点获取实时数据。所以我试着用最小延迟来循环。并有错误:

Exception RuntimeError: 'maximum recursion depth exceeded' in <bound method _fileobject.__del__ of <socket._fileobject object at 0x01D650F0>> ignored
此代码的错误

RuntimeError: maximum recursion depth exceeded in cmp
也许你们有解决方案来修复这个代码,或者你们有另一种从站点实时获取数据的方法

对不起,我的英语不好


谢谢

test
调用
open
哪个调用
test
;导致无限递归

改为使用循环来防止此类递归:

import urllib
import time
import os

def check(url):
    r = urllib.urlopen(url)
    html = r.read()
    if html != '-':
        print('ok')
        time.sleep(0.1)
        os.system('cls' if os.name == 'nt' else 'clear')

def test():
    while True:
        check('http://127.0.0.1/test/')

test()

顺便说一句,这是一个内置函数。通过将函数定义为
open
,它将隐藏内置函数。使用其他名称。

您能再显示一点异常的回溯吗?你不需要展示整个画面(可能有几百行),但你能给我们展示前几帧和最后几帧吗?@Blckknght谢谢你的回复,我只是尝试学习简单的代码,这是完整的代码。但现在已经解决了:Dhy!感谢您的回复,在我尝试使用“while true”之前,我忘记了为什么使用calls=))。我现在再试一次,然后再报告。非常感谢:)我认为这是工作,现在仍然循环没有错误D谢谢你@falsetru
import urllib
import time
import os

def check(url):
    r = urllib.urlopen(url)
    html = r.read()
    if html != '-':
        print('ok')
        time.sleep(0.1)
        os.system('cls' if os.name == 'nt' else 'clear')

def test():
    while True:
        check('http://127.0.0.1/test/')

test()