Lv.1
签名:上网。。。
在 Python高手帮帮我 中回复
代码:
from re import sub
from time import time
from lxml import etree
from requests import get
from ZC.pac import url_coding
i = 0
print("爬虫以开始运行\n----------------")
play = time()
while True:
i += 1
url = "http://www.doupoxs.com/doupocangqiong/" + str(i) + ".h喵l"
try:
url_get = get(url)
except BaseException:
print("检测出突喵况")
from os import _exit
_exit(0)
coding = url_coding(url_get.text)
a = coding.character()
url_get.encoding = str(coding)
url_etree = etree.H喵L(url_get.text)
url_xpath = url_etree.xpath("/h喵l/body/div[1]/div[2]/div[2]/p/text()")
if " ".join(url_xpath) == "":
break
txt_name = url_etree.xpath("/h喵l/body/div[1]/div[1]/h1/text()")
url_xpath = " ".join(url_xpath)
url_xpath = sub(" ", "\n ", url_xpath)
with open(" ".join(txt_name) + ".txt", "a+") as f:
f.write(" " + url_xpath)
f.close()
print(" ".join(txt_name))
end = time()
print("----------------\n爬虫已结束")
print("用时:" + str((end - play) // 1) + "s")2020-02-15T20:37:41 点赞:0
在 【Python作品分享】花摆线-Yeah【作业帖】 中回复
变量最好用英文!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2020-02-28T19:12:11 点赞:0
在 【Python作品分享】世上最让你眼花的一幅作品-----时空隧道【作品秀】 中回复
函数最好用英文!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2020-03-02T18:05:07 点赞:0
在 【Python作品分享】算年龄【教程贴】 中回复
print('您的年龄为:’+str(age)+‘岁')
错了,应为:
print('您的年龄为:', str(age), '岁')
总体为:
import datetime
imyear = input('年份:')
nowyear = datetime.datetime.now().year
age = (nowyear - int(imyear))
print('您的年龄为:', str(age), '岁')
if (age < 18):
print('您现在为未成年人 ~@_@~')
if (age >= 18 and age < 66):
print('您现在为成年人 (-_-)')
if (age >= 66 and age < 80):
print('您现在为中年人 ~@_@~')
if (age > 80):
print('您现在老年人 *-_-*')
2020-03-14T17:34:56 点赞:0
在 【Python作品分享】你好(海龟版)【作品秀】 中回复
加一个
turtie.done()
否则看不到!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2020-03-15T17:38:13 点赞:0
在 【Python作品分享】2019ncov病毒扩散图【作品秀】 中回复
这么多变量!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!






2020-03-21T16:26:00 点赞:0
在 【Python作品分享】图形【作业帖】 中回复
修改一下:
import turtle
__Pen = turtle.Pen()
KaloPen = turtle.Pen()
for i in range(4):
KaloPen.forward(100)
KaloPen.left(90)
KaloPen.forward(100)
KaloPen.left(60)
KaloPen.forward(60)
KaloPen.left(60)
KaloPen.forward(60)
KaloPen.left(60)
__Pen.right(60)
__Pen.backward(60)
__Pen.right(60)
__Pen.backward(60)
__Pen.left(60)
turtle.done()
2020-03-21T17:12:20 点赞:0