Python 给出语法错误但没有错误?

Python gives syntax error but there is no mistake?

有人能说说为什么 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

当我删除 def oyun(): 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])

它有效,但没有它们我无法制作我的程序。

确定没有语法错误?

win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])
                     12                                2  1???

报语法错误的行在语法错误的地方不需要。这只是早期语法错误导致解析器意识到出现问题的第一个地方。

查看报告错误上方的代码:

def mousePos(cord):
    win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])

您缺少右括号。