在Python中,当bytearray传递给函数时,它是通过引用传递还是通过值传递?
在python3.7中,我试图模拟HTTPResponse对象进行测试。当我从内部复制代码时http.client.HTTPResponse对象我得到的结果与标准库得到的结果不同。
我的代码:
#I call the mock buffer like this
intBytesBuffered = self.HTTPResponseMock.readinto(tempBuffer)
HTTPResponseMock
^{pr2}$相关函数来自http.client.HTTPResponse找到了here行436-500
标准库中最重要的摘录如下,read calls readinto:
b = bytearray(amt)
n = self.readinto(b)
return memoryview(b)[:n].tobytes()
标准库在调用缓冲区时做的事情和我差不多,但是当它运行时,摘录中的bytearry b
会返回其中的数据。当我调用read时,tempBuffer
返回空值?
目前没有回答
相关问题 更多 >
编程相关推荐