:os.startfileファイルが存在しないと言っていますが、それはありますか?私は、Windowsのコマンドを使用してPythonでフォルダからランダムに音楽ファイルを選択しようとしています
import os, random song = random.choice(os.listdir("C:\Users\MASONF\Music\Downloaded")) os.startfile(song)
それはエラーに
を返します。ここではrandom.choice()
os.listdir()
os.startfile()
コードですTraceback (most recent call last): File "C:\Users\MASONF\Desktop\successfuly chosen random file non existent.py", line 3, in <module> os.startfile(song) WindowsError: [Error 2] The system cannot find the file specified: 'Panda Eyes - Drippy Dub.mp3'
ファイルは存在しますが見つかりませんか?私は、Pythonに新しいですし、私はおそらく何かを明らかに見逃しているように、何のための多くのコマンドを知らない