ros.py 文件源码

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

项目:ROS-Code 作者: Richienb 项目源码 文件源码
def file(operation, path):
    operation = operation.lower()
    if operation == 'exists':
        import os.path
        return bool(os.path.isfile(path))
    elif operation == 'read':
        if file('exists', path):
            F = open(path, "w") 
            return F
        else:
            raise RuntimeError('An Error Has Occured: File Not Found (0012)')
    elif operation == 'delete':
        import os
        if file('exists', path):
            os.remove(path)
        else:
            raise RuntimeError('An Error Has Occured: File Not Found (0012)')
    elif operation == 'create':
        if not file('exists', path):
            f = open(path, "w+")
            f.close()
        else:
            raise RuntimeError('An Error Has Occured: File Already Exists (0013)')
    else:
        raise RuntimeError('An Error Has Occured: Invalid Operation Entered (0008)')

# Tools For Text Files
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号