utils.py 文件源码

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

项目:voiceid 作者: sih4sing5hong5 项目源码 文件源码
def ensure_file_exists(filename):
    """Ensure file exists and is not empty, otherwise raise an IOError.

    :type filename: string
    :param filename: file to check"""
    if not os.path.exists(filename):
        raise IOError("File %s doesn't exist or not correctly created" 
                      % filename)
    if not (os.path.getsize(filename) > 0):
        raise IOError("File %s empty" % filename)

    (shortname, extension) = os.path.splitext(filename)
    if sys.platform == 'win32' and extension=='.seg':
        import fileinput
        for line in fileinput.FileInput(filename,inplace=0):
            line = line.replace("\\\\","/")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号