Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4844

Troubleshooting • Re: VLC Player not working when included in startup script

$
0
0

Code:

from gpiozero import MotionSensorimport randomimport ospir = MotionSensor(23)                   while True:            pir.wait_for_motion()            songs = [f for f in os.listdir("/home/jasonc/Music") if f.endswith(".mp3")]            song = random.choice(songs)            os.chdir("/home/jasonc/Music")            os.system("vlc " + song)
If you're going to post python code you need to wrap it in [code][/code] tags. That retains the formatting.

It makes the difference between:
if code_tags = "used":
print ("Python code is formatted")
else:
print ("Python code is scrambled")

And:

Code:

if code_tags = "used":  print ("Python code is formatted")else:  print ("Python code is scrambled")

Statistics: Posted by DougieLawson — Sun Apr 28, 2024 10:01 am



Viewing all articles
Browse latest Browse all 4844

Trending Articles