2

即使所有部分都是字符串,我也收到以下 python 错误

    request = str(self.SETUP) + " " + str(self.fileName) + "RTSP/1.0";
TypeError: unsupported operand type(s) for +: 'int' and 'str'

整个代码部分:

if requestCode == self.SETUP and self.state == self.INIT:
    threading.Thread(target=self.recvRtspReply).start()
    # Update RTSP sequence number.
    self.rtspSeq = self.rtspSeq + 1

    # Write the RTSP request to be sent.
    request = str(self.SETUP) + " " + str(self.fileName) + "RTSP/1.0"


    # Keep track of the sent request.
    self.requestSent = request
4

1 回答 1

0

尝试这个:

if requestCode == self.SETUP and self.state == self.INIT:
    threading.Thread(target=self.recvRtspReply).start()
    # Update RTSP sequence number.
    self.rtspSeq = int(self.rtspSeq) + 1 

    # Write the RTSP request to be sent.
    rtps_req = "RTSP/1.0"
    request = "%s %s %s" % (str(self.SETUP),str(self.fileName), rtps_req)


    # Keep track of the sent request.
    self.requestSent = request
于 2013-01-17T00:51:28.473 回答