visualstudio_py_util.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:skojjt 作者: martin-green 项目源码 文件源码
def read_string(conn):
    """ reads length of text to read, and then the text encoded in UTF-8, and returns the string"""
    strlen = read_int(conn)
    if not strlen:
        return ''
    res = to_bytes('')
    while len(res) < strlen:
        res = res + conn.recv(strlen - len(res))

    res = utf_8.decode(res)[0]
    if sys.version_info[0] == 2 and sys.platform != 'cli':
        # Py 2.x, we want an ASCII string if possible
        try:
            res = ascii.Codec.encode(res)[0]
        except UnicodeEncodeError:
            pass

    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号