搜索到与相关的文章
Python

python爬虫(5)——BeautifulSoup & docker基础

BeautifulSoup基础实战安装:pipinstallbeautifulsoup4常用指令:frombs4importBeautifulSoupasbsimporturllib.requestdata=urllib.request.urlopen("https://www.cnblogs.com/mcq1999/").read().decode("utf-8","ignore")bs1=bs(data)print(bs1.prettify())#格式

系统 2019-09-27 17:50:47 2010

Python

python多进程间通信

这里使用pipe代码如下:importtimefrommultiprocessingimportProcessimportmultiprocessingclassD:@staticmethoddeftest(pipe):whileTrue:foriinrange(10):pipe.send(i)time.sleep(2)@staticmethoddeftest2(pipe):whileTrue:print('test2value:%s'%pipe.recv

系统 2019-09-27 17:49:29 2010

Python

python 字符串追加实例

通过一个for循环,将一个一个字符追加到字符串中:方法一:string=''str=u"追加字符"foriinrange(len(str)):string+=str[i]printstring显示结果:追加字符方法二:string=[]str=u"1234"foriinrange(len(str)):string.append(str[i])printstring显示结果:[u'1',u'2',u'3',u'4']以上这篇python字符串追加实例就是小编

系统 2019-09-27 17:48:12 2010

Python

Python中除法那些坑

Python中除法那些坑最近刷了一个cf题目,被python中的出发机制坑的不要不要的。这是链接:Chunga-Changapython中//和/的区别与使用a//b会获取值的整数部分,小数部分会丢失a/b会返回完整的值举个栗子:5//2=25/2=2.5那么问题来了?int(a/b)和a//b的区别在哪里呢?例1:int(7/3)=27//3=2既然如此讨论它们意义在上面地方呢?看看例二例二:int(999999999999999997/5)=20000

系统 2019-09-27 17:48:09 2010

Python

用Python遍历C盘dll文件的方法

python的fnmatch还真是省心,相比于java中的FilenameFilter,真是好太多了,你完成不需要去实现什么接口。fnmatch配合os.walk()或者os.listdir(),你能做的事太多了,而且用起来相当easy。#coding:utf-8"""遍历C盘下的所有dll文件"""importosimportfnmatchdefmain():f=open('dll_list.txt','w')forroot,dirs,filesinos

系统 2019-09-27 17:48:05 2010

Python

Node.js与PHP、Python的字符处理性能对比

测试用例分为用函数和类来进行一个大字符串的字符逐一读取。测试代码Node.js函数varfs=require("fs");varcontent=fs.readFileSync("page.html",{encoding:"utf-8"});functionchars(content){varlength=content.length;varpos=0;while(pos++

系统 2019-09-27 17:47:51 2010

Python

Python实现的tab文件操作类分享

类代码:#-*-coding:gbk-*-importosclassTABFILE:def__init__(self,filename,dest_file=None):self.filename=filenameifnotdest_file:self.dest_file=filenameelse:self.dest_file=dest_fileself.filehandle=Noneself.content=[]self.initflag=Falsesel

系统 2019-09-27 17:47:28 2010

Python

Linux下使用python自动修改本机网关代码分享

#!/usr/bin/python#autochangegatewayCreatedBymickelfengimportosimportrandom,reg='gateway192.168.1.'rand=random.randint(1,3)test='www.baidu.com'command='/etc/init.d/networkingrestart'GW="%s%d"%(g,rand)PingTest='ping-c3'+testtry:resu

系统 2019-09-27 17:46:54 2010

Python

python中下标和切片的使用方法解析

下标所谓下标就是编号,就好比超市中存储柜的编号,通过这个编号就能找到相应的存储空间。Python中字符串,列表,元祖均支持下标索引。例如:#如果想取出部分字符,可使用下标name="abcd"print(name[0])print(name[1])print(name[2])print(name[3])#输出结果为:#a#b#c#d切片切片是指对操作的对象截取一部分的操作,字符串,列表,元组均支持切片操作。切片的语法:[起始:结束:步长]注意:选取的区间属

系统 2019-09-27 17:46:49 2010

Python

深入了解Python数据类型之列表

一.基本数据类型整数:int字符串:str(注:\t等于一个tab键)布尔值:bool列表:list(元素的集合)列表用[]元祖:tuple元祖用()字典:dict注:所有的数据类型都存在想对应的类列里二.列表所有数据类型:基本操作:•索引•切片•追加•删除•长度•切片•循环•包含listclasslist(object):"""list()->newemptylistlist(iterable)->newlistinitializedfromiterab

系统 2019-09-27 17:46:22 2010