Search code examples
pythonpython-3.xgoogle-colaboratoryusb-drive

Can i save files to a usb drive in python


I am trying to make a recipe database for my grandma and I would like to learn how to save the recipes to an sd card.


Solution

  • You need to use open method, see below

    with open(usb_drive_location, "wb+") as file_obj:
        file_obj.write(uploaded_file.file.read())
    

    just add in your usb_drive_location and you will be good.