You can use the Linux crontab to run the Python script. Let's go to root and create a shell script.
sudo -i
nano startup.sh
Then type your python script on this bash script. navigate to home directory, then to this directory, then execute python script, then back home.
cd /
cd home/pi/your directory
sudo python yourpythonscript.py
cd /
Save the script and then exit. Make this sh script executable by giving it permission.
chmod 755 startup.sh
Now open and edit rc.local file.
nano /etc/rc.local
Add /root/startup.sh &
before exit 0
now save and exit from the file and reboot your pi.
sudo reboot
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…