I am trying to open a random mp3 file using python so that I can play a random song from my music playlist.
these are two variations of the code that I have tried
file = str('C:\file.mp3')
open(file)
or
open('C:\file.mp3')
When I run the program, I expect to see the Microsoft mp3 player to open and for the file to play but instead I get a pop-up message saying "Unicode error: 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape".
I have never used open()
before so if it is something very simple then I'm sorry.