Utils.py 文件源码

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

项目:SoCFoundationFlow 作者: mattaw 项目源码 文件源码
def readf_win32(f, m='r', encoding='ISO8859-1'):
    flags = os.O_NOINHERIT | os.O_RDONLY
    if 'b' in m:
        flags |= os.O_BINARY
    if '+' in m:
        flags |= os.O_RDWR
    try:
        fd = os.open(f, flags)
    except OSError:
        raise IOError('Cannot read from %r' % f)

    if sys.hexversion > 0x3000000 and not 'b' in m:
        m += 'b'
        f = os.fdopen(fd, m)
        try:
            txt = f.read()
        finally:
            f.close()
        if encoding:
            txt = txt.decode(encoding)
        else:
            txt = txt.decode()
    else:
        f = os.fdopen(fd, m)
        try:
            txt = f.read()
        finally:
            f.close()
    return txt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号