Python程序赢得';不执行 我正在做一个小游戏,包括侵入电脑,窃取文件和钱,以便完成任务。以下是截至目前的代码: #SICCr4k2: Broke # # # #Remember whenever you are printing a random ip address to add the "." in between each part of the ip (each random number) ## LAST LEFT ON HERE: MAKE BUTTONS FOR NODES ## MAKE FILES FOR NULL'S NODE ## SET THE CORRECT PLACEMENTS FOR ALL THE BUTTONS ## nullMain referenced before assignment ## make it so that you send a message through the prompt to get their ip, then it automatically puts the ip in the nodes ## window. Like you send the person a message, and then it gets the ip and puts it in the nodes window ## take away the buttons in the nodes window, just at labels where it points to the host's ip address. import random import time import sys import os import tkinter as tk from tkinter import * #def nodes(): # nodeWindow = tk.Tk() # frame = tk.Frame(nodeWindow, width=700, height=400) # frame.grid_propagate(0) # frame.grid() # nodeWindow.title("||| Nodes |||") # nullIp = tk.Label(nodeWindow, text="Ip: 221.153.52.216") # nullIp.grid(row=0, column=0) # nullMain = tk.Button(nodeWindow, text="Null", function=nullMainCallback()) # nullMain.config(height=1, width=100) # nullMain.grid(row=0, column=0) # def nullMainCallback(): # nullMain.destroy() # nullIp = tk.Label(nodeWindow, text="Ip: 221.153.52.216") # nullIp.grid(row=0, column=0) #def commands(): def numbers(): number1 = random.randint(1, 99) number2 = random.randint(1, 99) print(number1) if number1 != number2: numbers() if number1 == number2: os.system('cls') def ips(): nullIp = ('18.279.332') def getIp(): x = random.randint(1, 222) if x == 127: x += 1 return '{}.{}.{}.{}'.format( x, random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) def commandInput(): CommandInput = input(">>> ") if CommandInput == ("myNodes()"): nodes() else: commandInput() commandInput() def usernameCreation(): username = input(">>> ") print("'" + username + "' is that correct?") usernameInput = input(">>> ") if usernameInput == ("yes"): print("Okay...") if usernameInput ==("no"): usernameCreation() def game(): def tutorial(): print('Hello.') time.sleep(3) print('Welcome back.') time.sleep(3) print('How was it?') time.sleep(3) print('Being hacked for the first time?') time.sleep(3) print("You're probably wondering who I am.") time.sleep(5) print("Well, my name is Null.") time.sleep(3) print("Only because I am well known for nothing.") time.sleep(3) print("Other than not being alive.") time.sleep(3) os.system('cls') print("First thing's first, what shall I call you?") usernameCreation() print("Let's give you a bit of movement.") time.sleep(3) print("""The first thing you will want to do would be to connect to my computer, but to do that, you have to find my ip address. Here. I just uploaded new software to your computer.""") time.sleep(3) print("""You will now be able to access my ip, nad many other's with a simple command. The command is getIp(). Input that command below, but inside the parenthesis, you type in the screen name. For instance: getIp(Null). type that command in to get my ip.""") input(">>> ") if ("getIp(Null)"): numbers() print("""My ip was just added to your nodes, which you can access by typing myNodes().""") game()

Python程序赢得';不执行 我正在做一个小游戏,包括侵入电脑,窃取文件和钱,以便完成任务。以下是截至目前的代码: #SICCr4k2: Broke # # # #Remember whenever you are printing a random ip address to add the "." in between each part of the ip (each random number) ## LAST LEFT ON HERE: MAKE BUTTONS FOR NODES ## MAKE FILES FOR NULL'S NODE ## SET THE CORRECT PLACEMENTS FOR ALL THE BUTTONS ## nullMain referenced before assignment ## make it so that you send a message through the prompt to get their ip, then it automatically puts the ip in the nodes ## window. Like you send the person a message, and then it gets the ip and puts it in the nodes window ## take away the buttons in the nodes window, just at labels where it points to the host's ip address. import random import time import sys import os import tkinter as tk from tkinter import * #def nodes(): # nodeWindow = tk.Tk() # frame = tk.Frame(nodeWindow, width=700, height=400) # frame.grid_propagate(0) # frame.grid() # nodeWindow.title("||| Nodes |||") # nullIp = tk.Label(nodeWindow, text="Ip: 221.153.52.216") # nullIp.grid(row=0, column=0) # nullMain = tk.Button(nodeWindow, text="Null", function=nullMainCallback()) # nullMain.config(height=1, width=100) # nullMain.grid(row=0, column=0) # def nullMainCallback(): # nullMain.destroy() # nullIp = tk.Label(nodeWindow, text="Ip: 221.153.52.216") # nullIp.grid(row=0, column=0) #def commands(): def numbers(): number1 = random.randint(1, 99) number2 = random.randint(1, 99) print(number1) if number1 != number2: numbers() if number1 == number2: os.system('cls') def ips(): nullIp = ('18.279.332') def getIp(): x = random.randint(1, 222) if x == 127: x += 1 return '{}.{}.{}.{}'.format( x, random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) def commandInput(): CommandInput = input(">>> ") if CommandInput == ("myNodes()"): nodes() else: commandInput() commandInput() def usernameCreation(): username = input(">>> ") print("'" + username + "' is that correct?") usernameInput = input(">>> ") if usernameInput == ("yes"): print("Okay...") if usernameInput ==("no"): usernameCreation() def game(): def tutorial(): print('Hello.') time.sleep(3) print('Welcome back.') time.sleep(3) print('How was it?') time.sleep(3) print('Being hacked for the first time?') time.sleep(3) print("You're probably wondering who I am.") time.sleep(5) print("Well, my name is Null.") time.sleep(3) print("Only because I am well known for nothing.") time.sleep(3) print("Other than not being alive.") time.sleep(3) os.system('cls') print("First thing's first, what shall I call you?") usernameCreation() print("Let's give you a bit of movement.") time.sleep(3) print("""The first thing you will want to do would be to connect to my computer, but to do that, you have to find my ip address. Here. I just uploaded new software to your computer.""") time.sleep(3) print("""You will now be able to access my ip, nad many other's with a simple command. The command is getIp(). Input that command below, but inside the parenthesis, you type in the screen name. For instance: getIp(Null). type that command in to get my ip.""") input(">>> ") if ("getIp(Null)"): numbers() print("""My ip was just added to your nodes, which you can access by typing myNodes().""") game(),python,error-handling,Python,Error Handling,我只想指出,当我运行程序时,它不会列出任何错误或任何东西,它根本不会执行。。。有什么想法吗???你在游戏中定义了教程的功能(你不应该这么做,这样定义没有意义),但千万不要调用教程 在游戏中,您想调用教程: def game(): def tutorial(): # code for tutorial tutorial() 但是,构建代码的更好方法是使用main方法(这是启动程序执行的标准方法`并将所有其他函数分开。不需要像以前那样嵌套函数 例如: def mai

我只想指出,当我运行程序时,它不会列出任何错误或任何东西,它根本不会执行。。。有什么想法吗???

你在
游戏
中定义了
教程
的功能(你不应该这么做,这样定义没有意义),但千万不要调用
教程

游戏
中,您想调用
教程

def game():
    def tutorial():
        # code for tutorial
    tutorial()
但是,构建代码的更好方法是使用
main
方法(这是启动程序执行的标准方法`并将所有其他函数分开。不需要像以前那样嵌套函数

例如:

def main():
    tutorial()

# all other function definitions

def tutorial():
    # code for tutorial

if __name__ == "__main__":
    main()

您在
game
中定义函数
tutorial
(实际上您不应该这样做–这样定义没有意义),但从不调用
tutorial

游戏
中,您想调用
教程

def game():
    def tutorial():
        # code for tutorial
    tutorial()
但是,构建代码的更好方法是使用
main
方法(这是启动程序执行的标准方法`并将所有其他函数分开。不需要像以前那样嵌套函数

例如:

def main():
    tutorial()

# all other function definitions

def tutorial():
    # code for tutorial

if __name__ == "__main__":
    main()

您从不调用
tutorial()
,尽管您不应该嵌套这样的函数。

您从不调用
tutorial()
,尽管您不应该嵌套这样的函数。

提示:使问题标题更具描述性并提供提示:使问题标题更具描述性并提供