有人可以說爲什麼python不允許這樣做?Python給出語法錯誤,但沒有錯誤?
# -*- coding: utf-8 -*
import win32api,win32con,os,time,sys
x_pad =464
y_pad =235
def tik():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
print "Click.".decode('utf-8').encode(sys.stdout.encoding) #completely optional. But nice for debugging purposes.
def basilitut():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
print 'Hold'.decode('utf-8').encode(sys.stdout.encoding)
def birak():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
time.sleep(.1)
print 'Release.'.decode('utf-8').encode(sys.stdout.encoding)
def mousePos(cord):
win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])
def oyun():
#Ses kes
mousePos((163, 251))
tik()
time.sleep(.1)
#Play butonu
mousePos((161, 127))
tik()
time.sleep(.1)
#Iphone
mousePos((149, 267))
tik()
time.sleep(.1)
#Merhaba
mousePos((373, 314))
tik()
time.sleep(.1)
#Goal
mousePos((163, 251))
tik()
time.sleep(.1)
File "C:\Users\Doruk\Desktop\Python\Bot\code.py", line 27
def oyun():
^
SyntaxError: invalid syntax
當我刪除高清奧雲():blablabla
File "C:\Users\Doruk\Desktop\Python\Bot\code.py", line 24
^SyntaxError: invalid syntax
它只是給出了空行的錯誤。
當我刪除
def mousePos(cord):
win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])
它的工作原理,但我不能讓我的程序沒有他們。
在調試語法錯誤時,通常可以幫助將其解釋爲「在這個'def foo之前我期待看到其他東西(...'」 – JETM
錯誤報告在它們被檢測到的行*上, – cdarke