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

编程入门 行业动态 更新时间:2024-10-25 16:30:29
本文介绍了Python给出语法错误但没有错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有人能说为什么python不允许这样做吗?

# -*- 编码:utf-8 -*导入 win32api,win32con,os,time,sysx_pad =464y_pad =235def tik():win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)时间.睡眠(.1)win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)print "Click.".decode('utf-8').encode(sys.stdout.encoding) #完全可选.但用于调试目的很好.def basilitut():win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)时间.睡眠(.1)打印 'Hold'.decode('utf-8').encode(sys.stdout.encoding)def birak():win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)时间.睡眠(.1)打印 'Release.'.decode('utf-8').encode(sys.stdout.encoding)def mousePos(cord):win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])def oyun():#Ses kesmousePos((163, 251))抖音()时间.睡眠(.1)#播放按钮mousePos((161, 127))抖音()时间.睡眠(.1)#苹果手机mousePos((149, 267))抖音()时间.睡眠(.1)#梅哈巴mousePos((373, 314))抖音()时间.睡眠(.1)#目标mousePos((163, 251))抖音()时间.睡眠(.1)

<块引用>

文件C:\Users\Doruk\Desktop\Python\Bot\code.py",第 27 行

定义 oyun():

<代码> ^

语法错误:无效语法

当我删除那个 def oyun(): blablabla

<块引用>

文件C:\Users\Doruk\Desktop\Python\Bot\code.py",第 24 行

 ^ SyntaxError: 无效语法

它只是给出了带有空行的错误.

当我删除

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

它可以工作,但没有它们我无法制作我的程序.

解决方案

直接看上面报错的代码:

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

您缺少一个右括号.

Can someone say why python doesn't allow this?

# -*- 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

And when I remove that def oyun(): blablabla

File "C:\Users\Doruk\Desktop\Python\Bot\code.py", line 24

                                                            ^ SyntaxError: invalid syntax

It just gives the error with blank line.

And when I delete

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

It works but I can't make my program without them.

解决方案

Look at the code immediately above the reported error:

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

You're missing a closing parentheses.

这篇关于Python给出语法错误但没有错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 13:45:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1410194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但没   错误   语法错误   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!