每当我尝试通过python连接到mysql时,都会出现此烦人的错误,请帮助我,请帮助我

问题描述

def project():
    import MysqL.connector as mycon
    import pypng
    from PyQRCode import QRCode 
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    con=mycon.connect(host="localhost",user="clash",password=6969,database="alapan")
    cur=con.cursor()
    #MAIN PART
    while(True):
        print("""which movie do u want to watch 1.Dil Bechara 2. 3 Idiots 3.Dhammal 4.Harry Potter 5.Endgame
        Please enter your choice!""")
        ch=int(input("->"))
        mov={1:"Dil Bechara",2:"3 Idiots",3:"Dhammal",4:"Harry Potter",5:"Endgame"}
        movie=mov[ch]
        cost=250
        print("""Select City A.Kolkata B.Delhi C.Mumbai D.Bangalore E.Hyderabad""")
        ch1=input("->")
        di={'A':"KOLKATA",'B':"DELHI",'C':"MUMBAI",'D':"BANgalORE",'E':"HYDERABAD"}
        st="SELECT HALLS FROM"+str(di[ch1]+str(ch))
        cur.execute(st)
        con.commit()
        res=cur.fetchall()
        k=0
        for row in res:
            print(k,row)
            k+=1
        print("ENTER YOUR CHOICE")
        ch2=int(input("->"))
        st2="SELECT SEATS FROM "+str(di[ch1])+"WHERE HALL="+str(res[ch2])
        cur.execute(st2)
        con.commit()
        res2=cur.fetchall()
        print(res2)
        print("Please select the number of seats from the avaliable seats given above")
        ch3=int(input("->"))
        cur.execute("SELECT SEATS FROM "+str(di[ch1])+"WHERE HALL="+str(res[ch2]))
        con.commit()
        print("SELECT TIME P.MORNING Q.AFTERNOON R.NIGHT")
        ch4=input("Enter your choice")
        di2={'P':"MORNING",'Q':"AFTERNOON",'R':"NIGHT"}
        tme=di2[ch4]
        print("SELECT TIER I.broNZE II.SILVER III.GOLD ")
        ch5=input("->")
        if ch5=='II':
            cost+=100
        elif ch5=="III":
            cost+=200
        print("Do u want to confirm ? Y/N")
        print(movie,"\n",str(di[ch1]),str(res[ch2],ch3,tme,ch5))#MOVIE,CITY,HALL,SEATS,TIME,TIER 
        ch6=input("->")
        if ch6.upper()=='Y':
            #here we have to change the seat number
            st3="SELECT SEATS FROM"+str(di[ch1]+str(ch))+"WHERE SEATS=SEATS-%d"%(ch3)
            cur.execute(st3)
            con.commit()
            if ch==1:
                url="https://in.bookmyshow.com//movies/dil-bechara/ET00098454"
            elif ch==2:
                url="https://in.bookmyshow.com/movies/3-idiots/ET00001611"
            elif ch==3:
                url="https://in.bookmyshow.com/movies/dhamaal/ET00000016"
            elif ch==4:
                url="https://in.bookmyshow.com/movies/harry-potter-and-the-deathly-hallows-part-2/ET00007363"
            else:
                url="https://in.bookmyshow.com/movies/avengers-endgame/ET00090482"
            qrc= pyqrcode.create(url) 
            print("Scan the qrcode saved un your python directory and scan to complete payment")
            qrc.svg("myqr.svg",scale = 8) 
            qrc.png('myqr.png',scale = 8)
            break
        else:
            break
    con.close()
if __name__=='__main__':
    project()

显示错误---:

Traceback (most recent call last):
  File "C:\Users\clash\AppData\Local\Programs\Python\python38\Programs\Project.py",line 75,in <module>
    project()
  File "C:\Users\clash\AppData\Local\Programs\Python\python38\Programs\Project.py",line 2,in project
    import MysqL.connector as mycon
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\__init__.py",line 37,in <module>
    from .connection import MysqLConnection
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\connection.py",line 31,in <module>
    from .authentication import get_auth_plugin
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\authentication.py",line 29,in <module>
    from . import errors
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\errors.py",line 27,in <module>
    from . import utils
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\utils.py",line 33,in <module>
    from .catch23 import struct_unpack
  File "C:\Users\clash\AppData\Local\Programs\Python\python38-32\lib\site-packages\MysqL\connector\catch23.py",line 26,in <module>
    from decimal import Decimal
ImportError: cannot import name 'Decimal' from 'decimal' (C:\Users\clash\AppData\Local\Programs\Python\python38\Programs\decimal.py)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...