当前位置:首页 > python笔记 第2页

python 获取当前的路径并切换

zhangchap3年前 (2021-06-05)282
import os curdir = os.path.dirname(__file__) #获取当前的路径,若运行在当前文件夹,是获取不到当前路径的,最保险的...

python函数开启多线程

zhangchap3年前 (2021-06-05)240
from threading import Thread 以下是代码举例: def main(num):    &nbs...

python列表排序(以字符串长度)

zhangchap3年前 (2021-06-04)263
M = ['a', 'sss', 'bb'] 第一种: m = M.sort(key&n...

json输出json.dumps中文为ascii编码如何解决?

zhangchap3年前 (2021-06-03)324
import json print json.dumps('中国') 输出:"\u4e2d\u56fd" json.dumps(...

python fake_useragent 模块用法

zhangchap3年前 (2021-06-01)311
我们每次发送requests请求时通过random从中随机获取一个随机UserAgent,两行代码即可完成UserAgent的不停更换 from fake_useragent i...

python url.parse模块编码解码

zhangchap3年前 (2021-05-29)290
from urllib.parse import quote,unquote,urlencode # 对汉字进行编码使用 quote ...

python jieba分词

zhangchap3年前 (2021-05-25)263
import jieba from jieba.analyse import tfidf words = jieba.lcut('...

python 随机生成时间戳写入txt文件/运行sql语句

zhangchap3年前 (2021-05-20)473
import time from random import randint with open('time.txt', ...

python xpath语法总结

zhangchap3年前 (2021-05-20)244
python xpath语法总结:常用的://1.从任意节点开始/2.从根节点开始//div/p3.div下的p标签//div[@class="hrzz_bottom"]/ul/l...

python补全网址代码示例

zhangchap3年前 (2021-05-19)345
from urllib.parse import urljoin absurl = urljoin(backend,url) #backend:根...