我有一个 TCP 客户端服务器通信。我正在发送字符串,我想测量包裹的大小,我该怎么做?
就我而言,sys.getsizeof不好,因为
getsizeof() calls the object’s __sizeof__ method and adds an additional garbage collector
overhead if the object is managed by the garbage collector.
一个字符的大小是多少,2 字节还是 4 字节?在这种情况下,我可以简单地测量 as msg_size = x * len(msg)
,但我不知道有多少字节x