How do I mount a filesystem using Python?

前端 未结 10 1967
鱼传尺愫
鱼传尺愫 2020-12-16 09:41

I\'m sure this is a easy question, my Google-fu is obviously failing me.

How do I mount a filesystem using Python, the equivalent of running the shell command

10条回答
  •  清歌不尽
    2020-12-16 10:12

    Another option would be to use the fairly new sh module. According to its documentation it provides fluent integration with Shell commands from within Python.

    I am trying it out now and it looks very promising.

    from sh import mount
    
    mount("/dev/", "/mnt/test", "-t ext4")
    

    Also take a look at baking, which allows you to quickly abstract away commands in new functions.

提交回复
热议问题