August 2018
Intermediate to advanced
366 pages
10h 14m
English
The steps for this recipe are as follows:
import pathlib
import webbrowser
def playfile(fpath):
fpath = pathlib.Path(fpath).expanduser().resolve()
webbrowser.open('file://{}'.format(fpath))
>>> playfile('~/Pictures/avatar.jpg')
>>> playfile('~/Music/FLY_ME_TO_THE_MOON.mp3')
So, we can use this method on most systems to show the content of a file to the user.