granular_bastard
granular_bastard

Reputation: 187

Accessing an image from storage of a plugged in Android phone, on Windows with Python

Using Python in Win10, I want to read a picture that is on the SD card of an Android phone. The phone is connected to the Windows computer via USB.

If the image is on the local hard drive, I can use

file = r'D:\0.png'
handle = open(file)

The directory for the file on the SD card as displayed in the Windows Explorer is

file = r'This PC\Redmi Note 11\SD-карта\0.png'

However, Python will not find the image in that directory. Note the Cyrillic 'карта'. Listing all available drives by Python (Link) does not show the SD card or phone. What path definition should I use in Python to access the image from the SD card?

Upvotes: -1

Views: 303

Answers (1)

karlphillip
karlphillip

Reputation: 93410

Start the investigation by figuring out which drives are available on Windows as "This PC" is not a valid name when trying to access file programatically.

Next, print the root directories of that drive and slowly build a string that contains the full path to that image.

Upvotes: 0

Related Questions