如何使代码块从python中的原始输入运行

2024-05-19 10:52:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有个问题。我对python非常陌生,但我正在尝试做一个黑客助手,只需问一下就可以运行攻击和扫描。我昨晚刚开始做一个基本的端口扫描器,我在另一个.py文件中写了端口扫描器,现在如果用户键入“port scanner”“Will you scan a port for me?”等,我该如何运行它。 此外,每当我键入笑话它不运行笑话块的代码,它只是运行端口扫描程序

# coding: utf-8
#!/usr/bin/env python
import time

if Home == "portscanner" or "Portscanner" or "Will you scan a port for     me?":
portscanner()


######This starts the code for the machine responding with jokes

if Home == "Tell me a joke" or "Joke" or "joke" or "do you know any     jokes?" or "Do you know any jokes":
    #Joke section this is purely cosmetic and funny for the user gonna add more features like this
from random import *
def joke():
joke1 = "I like telling UDP jokes because I don't care if you don't get them"
joke2 = "CAPS LOCK - Preventing Login Since 1980."
joke3 = "In a world without fences and walls, who needs Gates and Windows?"
joke4 = "I once had an idea.....oh wait nope that was my maker...I'm a program...I don't have ideas"
joke5 = "Programmers are tools for converting caffeine into code."
joke6 = "Hacking is like sex...You get in, you get out, and hope that you didn’t leave something that can be traced back to you."
joke7 = "!false - its funny because its true"
joke8 = "<joke>Joke Here</joke>"
joke9 = "Hide&Seek champion - ; - Since 1958"
headers = [joke1, joke2, joke3, joke4, joke5, joke6, joke7, joke8, joke9]
print headers[randint(0,8)]

Tags: orandtheyouforgetifport
1条回答
网友
1楼 · 发布于 2024-05-19 10:52:44

使用scanner.py创建文件:

def scan():
    # Do you scan

然后在主文件中从用户处获取字符串:

import scanner

Home = input()
if Home == "portscanner" or "Portscanner" or "Will you scan a port for me?":
    scanner.scan()

相关问题 更多 >

    热门问题