해킹이나 해킹과 같은 해킹 게임을 만들려고합니다. 그러나 터미널 만. 내가 라인 86에서 변수 'currentip을'인쇄하려고 할 때이 오류가 ("인쇄 ("당신은에서 현재 "+ currentip +" ")가".) :파이썬 코드에서 오류를 찾을 수 없습니다.
UnboundLocalError: local variable 'currentip' referenced before assignment
이것은 간단한 오류처럼 보이는 그러나 나는 그것을 이해할 수 없다. 나는 그것을 지정했다. 여러 번. 어쩌면 주문 실행을 잘못 읽은 것입니다.하지만 내가 잘못하고 있다고 말하는 정보를 찾을 수 없습니다 ...
깔끔하고 깨끗하게 만드는 아이디어는 매우 높이 평가됩니다.
import os
import random
from time import sleep
os.system("cls")
save = {}
ips = {"1337.1337.1337.1337": "Cheater's Stash"}
shells = []
storyips = ["Bitwise Test PC"]
currentip = "1.1.1.1"
homeip = "1.1.1.1"
def resetip():
ip1 = random.randint(1, 999)
ip2 = random.randint(1, 999)
ip3 = random.randint(1, 999)
ip4 = random.randint(1, 999)
homeip = str(ip1) + "." + str(ip2) + "." + str(ip3) + "." + str(ip4)
if homeip in ips:
resetip()
else:
ips[homeip] = "Your Computer"
currentip = homeip
def storyreset():
for x in storyips:
ip = (0, 0, 0, 0)
ip1 = random.randint(1, 999)
ip2 = random.randint(1, 999)
ip3 = random.randint(1, 999)
ip4 = random.randint(1, 999)
ip = str(ip1) + "." + str(ip2) + "." + str(ip3) + "." + str(ip4)
if ip in ips:
storyreset()
else:
ips[ip] = x
def start():
os.system("cls")
print("Python 3.5, HackSim 1.1")
print("")
print("Loading modules...")
print("")
sleep(1)
print("OS Loaded.")
sleep(0.5)
print("HELP Loaded.")
sleep(0.5)
print("FILE USE Loaded.")
sleep(1)
print("CONNECTIONS Loaded.")
sleep(0.5)
print("UTILS Loaded.")
sleep(0.5)
print("HACKS Loaded.")
print("")
sleep(1)
print("Initiating command line...")
sleep(1)
commandline()
def usecommand(c):
if c == "reboot":
print("Rebooting...")
sleep(3)
start()
elif c == "clear":
os.system("cls")
elif c == "quit":
quit()
elif c == "forkbomb":
del ips[currentip]
if homeip in ips:
currentip = "Your Computer"
else:
resetip()
currentip = "Your Computer"
elif "connect " in c:
if c[8:] in ips:
connectip = ips[c[8:]]
print("Connecting to ", connectip, " ", c[8:], "...")
currentip = connectip
else:
print("This ip does not exist.")
elif c == "connect":
print("You are currently at " + currentip + ".")
print("The syntax of this command is: connect <ip>.")
else:
print("Invalid command. Either the command does not exist or check the required syntax.")
def commandline():
while True:
command = input("> ")
usecommand(command)
storyreset()
resetip()
start()
고마워요!
소스 코드의 관련 부분과 프로그램을 실행할 때 얻을 수있는 오류 스택 추적 정보를 여기에 게시하십시오. –
Stacktrace : http://pastebin.com/DkYdgPDV –
관련 부분은 ... 단서가 없습니다. 저는 파이썬으로 초보자입니다. –