sudo apt install python-rpi.gpio
import RPi.GPIO as GPIO
import time

relay_pin = 23 #Change PIN If Needed

GPIO.setmode(GPIO.BCM)
GPIO.setup(relay_pin,GPIO.OUT)

try:
        while True:
                #set low
                print ("Setting low - ON")
                GPIO.output (relay_pin,GPIO.LOW)
                time.sleep(2) #Time Is In Seconds
                #set high
                print ("Setting high - OFF")
                GPIO.output (relay_pin, GPIO.HIGH)
                time.sleep(2) #Time Is In Seconds
except KeyboardInterrupt:
        GPIO.cleanup()
        print ("Done")