![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
beast520
这个作者很懒,什么都没留下…
展开
-
xpath
#找到虚构类和非虚构类的所有图书all_book = lhtml.xpath('//div[@class="article" or @class="aside"]//li/div')for book in all_book: #找到图书标题 book_title = re.sub(r'[\n\t\s]+','',''.join(book.xpath('h2//tex...原创 2019-10-16 21:05:56 · 106 阅读 · 1 评论 -
python 3列表 操作 练习
python 3列表 操作python 3列表的练习,随时编辑更新#!user bin/env python#coding=utf-8import timeimport syslog = list(r’print(logshort[0][0][0])’)‘’’print(time.process_time_ns())for i in range(0,1000):#log[2]=...原创 2019-09-21 17:59:39 · 286 阅读 · 0 评论 -
python 变量 列表容易出的小错误。
person = {"name":' ',"id":0}team = [ ]for i in range(3): x = person x["id"] = i team.append(x)team[0]["name"]= "jack"team[1]["name"]="Pony"team[2]["name"]="alex"print(team[1])请问输出是什么样?1{‘n...原创 2019-09-21 19:38:29 · 127 阅读 · 0 评论 -
python修改替换文件每行的指定字符
#简单的修改文件里的字符串有个朋友经常要修改一大堆文件里指定字符的批量修改所以写了下面一段代码:filename =".\\modified.txt"hand =str(input("前缀词:")).strip()endwith =str(input("后缀词:")).strip()change = str(input("要修改的整数初始值"))filenamehand = ope...原创 2019-09-23 12:29:45 · 1777 阅读 · 0 评论