![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 78
mangguochang
这个作者很懒,什么都没留下…
展开
-
Linux中使用vim编写python程序提示功能
1.mkdir ~/.vimmkidr ~/.vim/bundlecd ~/.vim/bundle这里我们可以自己下载好上传到linux系统中git clone https://github.com/rkulla/pydiction.git 2.把下载下来的after复制到.vim目录下:cp -r ~/.vim/bundle/pydiction/after/ ~/...原创 2018-11-06 23:30:25 · 1286 阅读 · 2 评论 -
Python协程的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import geventfrom gevent import monkeyimport urllibimport urllib.request as request """"1.为什么需要使用协程呢?从一个业务场景来说吧:比如我们写了一个程序对某个网站的数据进行抓取...原创 2018-11-05 20:46:55 · 804 阅读 · 0 评论 -
Python爬虫捉取数据(代理网站)
#!/usr/bin/evn python# -*- coding:utf-8 -*-import urllib2import urllibimport refrom HTMLParser import HTMLParser # 代理信息实体class ProxyObj:proxyAddress="" #代理服务器地址proxyPort=0 #代理服务器端口...原创 2018-11-05 20:49:55 · 217 阅读 · 0 评论 -
Python拿到Cookie对象并实现登录目标系统的案例
#!/usr/bin/evn python# -*- coding:utf-8 -*-import cookielibimport urllib2import urllib# 通过使用cookielib对象的CookieJar()方法创建一个保存cookie的对象cookie=cookielib.CookieJar(); #使用HTTPCookieProcessor...原创 2018-11-05 20:52:01 · 525 阅读 · 0 评论 -
Python随机函数的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import random strs="asjfalskgdjlljkasjdflkajsdlkfjsaldf";ss="";# 产生10个随机的字段出来for i in range(0,10):'''使用random choice的方法可以进行,直接把对象传入到choic...原创 2018-11-05 20:53:02 · 1507 阅读 · 0 评论 -
python中使用PyMysql操作Mysql数据库用例
import pymysqlimport pymysql.cursors """连接mysql数据库"""conn=pymysql.connect(host='192.168.199.133',port=3306,user='root',passwd='123456',db='simondb');"""获得游标操作对象"""cursor=conn原创 2018-11-05 20:54:15 · 226 阅读 · 0 评论 -
在Python中使用Xpath进行数据爬取的案例
#!/usr/bin/evn python# -*- coding:utf-8 -*-import urllib2import urllibfrom lxml import etreeclass proxyObj:proxyService="";proxyPort=""proxyHttp="http"proxy_headers={"User-Agent": ...原创 2018-11-05 21:03:10 · 1517 阅读 · 0 评论 -
Python中输入输出的方法使用
#!/usr/bin/env python# -*-coding:utf-8 -*-import osimport re parter="(13|15|18)\d{9}";strs="simonmegn13056865679www.techportal.cn2018-1-01";strss=re.search(parter,strs);if strss is not...原创 2018-11-05 21:59:56 · 1022 阅读 · 0 评论 -
Python的基本语法
#/usr/bin/pythonprint("simong" );"""定义一个变量"""temp_var=1;"""条件控制语句"""if(temp_var): print("temp_var"); print(temp_var); tempstr="APfel".en原创 2018-11-05 22:01:14 · 131 阅读 · 0 评论 -
Python的函数使用
#注释是使用“#”号来的print("Hello Python!!!!");#定义一个方法def sayHello(): print("Hello simon!!!"); a=1; b=2; #声明一个变量 if(a>b): print("a>b"); else: print("a<...原创 2018-11-05 22:01:58 · 218 阅读 · 0 评论 -
Python中使用线程进行排队处理任务
由于Python语言本身是没有支持线程池的api,所以我自己看一些教程和文章,自己写了一个demo,直接上码:#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport Queueimport timeimport contextlib"""创建一个线程池对象"""class Threa...原创 2018-11-05 20:43:13 · 2681 阅读 · 1 评论 -
Python中修改pip工具的默认下载源网站
1.python中一般使用pip默认的下载网站时,在国内使用可能会连接超时,如以下这种情况: 2.后来看了一些网站的博客,才知道,python的官网有一段这样的一个说法:On Unix the default configuration file is: $HOME/.config/pip/pip.conf which respects the XDG_CONFIG_HOME ...原创 2018-11-04 23:35:39 · 10567 阅读 · 7 评论 -
Python中使用正则表达不区分大小写与Split的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import reimport lxmlfrom xml import etreepantern=re.compile(r"[\s\d\\a\\n\;]+");result=pantern.split("aaa 1235\nfskajd;sim on")print(result)p...原创 2018-11-06 23:30:58 · 2323 阅读 · 0 评论 -
Python中使用threading实现多线程的方法
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport time """定义一个方法"""def simonAction(i):#让当前的线程,沉睡1stime.sleep(1)print("i is "+str(i)+"\n") for i in range(0,10)...原创 2018-11-06 23:31:44 · 151 阅读 · 0 评论 -
python多线程的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport time'''自定义一个thread类,并使用自定义类创建线程'''class myThread(threading.Thread):def run(self):#当前线程沉睡1s时间time.sleep(1)print("...原创 2018-11-06 23:32:23 · 125 阅读 · 0 评论 -
Python中使用线程锁的案例
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport randomimport timeimport os # 声明一个线程锁lock=threading.Lock() count=100;#买票的方法def saleTicket():global count#如果...原创 2018-11-06 23:32:59 · 224 阅读 · 0 评论 -
Python中Event的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport os # python中的Event的使用eventobj=threading.Event();def testEvent():print("start----------------\n")#等待用户输入指令eventobj....原创 2018-11-06 23:33:28 · 5757 阅读 · 0 评论 -
Python中消息队列的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport Queueimport time # 创建一个消息队列message=Queue.Queue(); # 生产者的方法def producer():for i in range(0,10000):# 把系统消息压到队列当中...原创 2018-11-06 23:34:01 · 1756 阅读 · 0 评论 -
Python的多进程的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-#多进程的使用import multiprocessingimport timefrom multiprocessing import Process def simontestfun():print("this is simontestfun!!!!!!")print(__n...原创 2018-11-06 23:35:48 · 106 阅读 · 0 评论 -
Python中线程与队列的组合使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import threadingimport multiprocessingimport Queueimport time class myThread(threading.Thread):def run(self):print("Thread-"+self.name+" St...原创 2018-11-06 23:36:38 · 445 阅读 · 0 评论 -
Python进程池的使用
#!/usr/bin/evn python# -*- coding:utf-8 -*-import multiprocessingimport timeimport threadingfrom multiprocessing import Pool,Array,Value,Queuedef simonPoolTest(name,action):print("你传入进来的...原创 2018-11-07 09:11:49 · 724 阅读 · 0 评论 -
Python的标识符
Python中我们在编程的时候,起的名称就叫做标识符。其中变量和常量就是标识符的一种。 Python中的标识符命名原则: 在Python中的标识符的命名是有规则的。按正确命名规则命名的可以使用的标识符叫做有效标识符,否则不能使用的标识符叫做无效标识符。有效标识符命名有以下的几点规范: 标识符第一个字符必须只能是字母或下划线,第一个字...原创 2018-11-06 09:02:00 · 1124 阅读 · 0 评论