我正在爲其中一個受歡迎的MMORPG製作自動化腳本。我收到以下錯誤:Python名稱錯誤:全局名稱'inv'未定義
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
startFishing()
File "C:\Python27\DG\RS\RS bot.py", line 56, in startFishing
if inv == "full":
NameError: global name 'inv' is not defined
我已在下面詳細介紹了我的功能。
def isMyInventoryFull():
s = screenGrab()
a = s.getpixel((1173,591))
b = s.getpixel((1222,591))
c = s.getpixel((1271,591))
d = s.getpixel((1320,591))
if a == b == c == d:
print "Inventory is full! Time to go back home."
inv = "full"
print inv
else:
print "Inventory is not full."
inv = "notfull"
time.sleep(3)
def startFishing():
mousePos((530,427))
leftClick()
time.sleep(0)
inv = 'full'
openUpInventory()
isMyInventoryFull()
if inv == "full":
time.sleep(0.01)
else:
isMyInventoryFull()
mousePos((844,420))
rightClick()
time.sleep(1)
的事情是,我有我的「isMyInventoryFull」功能中定義的「INV」,但它不是拿起那INV「已經被定義?我絕對錯過了一些東西,任何人都可以幫忙嗎?
請解決您的壓痕。將代碼粘貼到框中,然後突出顯示,然後單擊「{}」。 – geoffspear