第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

執(zhí)行代碼出錯(cuò),卿幫忙找一下原因

from urllib.request import urlopen

from bs4 import BeautifulSoup as bs

import re

import pymysql

resp=urlopen("https://en.wikipedia.org/wiki/Main_Page").read().decode("utf-8")

soup=bs(resp,"html.parser")

listurls=soup.findAll("a", href=re.compile("^/wiki/"))

#print(listurls)

for url in listurls:

? ? if not re.search("\.(jpg|JPG)",url["href"]):

? ? ? ? print(url.get_text(),"<------->","https://en.wikipedia.org"+url["href"])


conn = pymysql.connect(host="localhost",

? ? ? ? ? ? ? ? ? ? ? ? user="root",

? ? ? ? ? ? ? ? ? ? ? ? password="xuanbg126",

? ? ? ? ? ? ? ? ? ? ? ? db="wikiurl",

? ? ? ? ? ? ? ? ? ? ? ? charset="utf8mb4" )

try:

? ? ? with conn.cursor()as cur:

? ? ? ? ?sqll="insert into 'testurl'('urlname','urlhref')values(%s,%s)"

? ? ? ?

? ? ? ? ?cur.execute(sqll,(url.get_text(),"https://en.wikipedia.org"+ url["href"]))


? ? ? ? ?conn.commit()

#except HandlException as e:

? ? ? #conn.rollback()

finally:

? ??

? ? conn.close()

errr ifn:

Traceback (most recent call last):

? File "C:/Users/morgan/Desktop/bao2/feq1.py", line 22, in <module>

? ? cur.execute(sqll,(url.get_text(),"https://en.wikipedia.org"+ url["href"]))

? File "C:\Program Files\Python35\lib\site-packages\pymysql\cursors.py", line 166, in execute

? ? result = self._query(query)

? File "C:\Program Files\Python35\lib\site-packages\pymysql\cursors.py", line 322, in _query

? ? conn.query(q)

? File "C:\Program Files\Python35\lib\site-packages\pymysql\connections.py", line 835, in query

? ? self._affected_rows = self._read_query_result(unbuffered=unbuffered)

? File "C:\Program Files\Python35\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result

? ? result.read()

? File "C:\Program Files\Python35\lib\site-packages\pymysql\connections.py", line 1302, in read

? ? first_packet = self.connection._read_packet()

? File "C:\Program Files\Python35\lib\site-packages\pymysql\connections.py", line 981, in _read_packet

? ? packet.check_error()

? File "C:\Program Files\Python35\lib\site-packages\pymysql\connections.py", line 393, in check_error

? ? err.raise_mysql_exception(self._data)

? File "C:\Program Files\Python35\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception

? ? raise errorclass(errno, errval)

pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''testurl'('urlname','urlhref')values('Disclaimers','https://en.wikipedia.org/wik' at line 1")


正在回答

4 回答

解決了:

sqll="insert into? testurl (urlname, urlhref)values(%s,%s)"

按照上面這樣修改即可,注意testurl后面的空格

2 回復(fù) 有任何疑惑可以回復(fù)我~

我也想知道,為什么會(huì)這樣子呢?

0 回復(fù) 有任何疑惑可以回復(fù)我~

請(qǐng)問(wèn)解決了么?

0 回復(fù) 有任何疑惑可以回復(fù)我~

sql 語(yǔ)法錯(cuò)誤.

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

執(zhí)行代碼出錯(cuò),卿幫忙找一下原因

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)