txt2tags.py 文件源码

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

项目:temporal-planning 作者: aig-upf 项目源码 文件源码
def Readfile(file_path, remove_linebreaks=0, ignore_error=0):
    data = []
    if file_path == '-':
        try:
            data = sys.stdin.readlines()
        except:
            if not ignore_error:
                Error(_('You must feed me with data on STDIN!'))
    else:
        try:
            f = open(file_path)
            data = f.readlines()
            f.close()
        except:
            if not ignore_error:
                Error(_("Cannot read file:") + ' ' + file_path)
    if remove_linebreaks:
        data = map(lambda x:re.sub('[\n\r]+$', '', x), data)
    Message(_("File read (%d lines): %s") % (len(data), file_path), 2)
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号