![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
skalpat
这个作者很懒,什么都没留下…
展开
-
pycharm 不能使用turtle 总是出现闪退
最后加上一句turtle.done()即可解决原创 2019-11-11 16:57:58 · 1301 阅读 · 0 评论 -
mac下使用mono运行Fiddler!!
1.MAC安装mono从Mono 官网https://www.mono-project.com/download/stable/下载下载时页面会展示有相应的版本号,记住版本号,我下载的是5.16.0,所以接下来的<Mono Version>全都替换成5.16.0安装完之后执行/Library/Frameworks/Mono.framework/Version...原创 2019-09-02 14:44:10 · 998 阅读 · 0 评论 -
python 报错 AttributeError: 'generator' object has no attribute 'next'
在python3.x版本中,python2.x的g.next()函数已经更名为g.__next__(),所以只需要将g.next()换成g.__next__()就可以了。但是经我测试,python2 中不能用next() 然而 python3中可以用.__next__()...原创 2019-07-28 09:45:04 · 963 阅读 · 0 评论 -
搭建django 框架
1 搭建 irtualenv 虚拟环境sudo pip install virtualenvsudo pip install virtualenvwrapper2 安装 django 框架sudo pip3 install django==1.11.8 这是python3的sudo pipinstall django==1.11.8 这是python2的安...原创 2019-08-05 17:17:59 · 110 阅读 · 0 评论 -
python 进程间通信的几种方式
方式一: 使用multiprocessing.Queue()用Process 创建的进程间的通信用from multiprocessing import Queueq = Queue(3)q.qsize()0q.put("haha")q.qsize()1方式二:要使用 multiprocessing.Manager()中的Queue()用进程池创建...原创 2019-07-22 17:35:28 · 2269 阅读 · 0 评论 -
Raises NotImplementedError on Mac OSX because of broken sem_getvalue()
运行qsize 在mac os 上不能运行但是在Linux上是可行的原创 2019-07-22 15:38:58 · 942 阅读 · 0 评论 -
python 创建进程的几种方式及比较
方式一 ret = os.fork()if ret ==0:#子进程else: #父进程#这种方式很少用方式二:p1 = Process(target=xxxx)p1.start()#主进程和子进程都可以执行方式三:pool = Pool(3)pool.apply_async(xxxxx)#主进程一般用来等待,...原创 2019-07-22 11:53:49 · 319 阅读 · 0 评论 -
python 进程和线程关于函数内的变量与全局变量的异同
函数内的变量线程和进程完成多任务的时候都不共用全局变量线程是共用的,但是进程不共用,各人是各人的原创 2019-07-25 10:05:19 · 296 阅读 · 0 评论 -
Python 私有化方法
注意from somemodule import * 禁止导入import somemodule 是可以导入原创 2019-07-12 15:26:20 · 670 阅读 · 0 评论 -
Python 位运算
左移是乘 例如,左移一位是乘以2右移是除例如,右移一位是除以2原创 2019-07-12 13:59:45 · 110 阅读 · 0 评论 -
python 进制间的相互转换
0o 开头是8进制0b 开头是2进制0x 开头是16进制原创 2019-07-12 11:50:10 · 144 阅读 · 0 评论 -
浅拷贝与深拷贝
浅拷贝:深拷贝:原创 2019-07-12 09:48:50 · 147 阅读 · 0 评论 -
python 进行pdb调试
l ---->list 显示当前代码n ---->next 向下执行一行代码c ---->continue 继续执行代码b ---->break 添加断点clear 删除断点p---->print 打印一个变量的值a --->args 打印所有的形参数据...原创 2019-07-18 16:30:42 · 113 阅读 · 0 评论 -
python 创建类的几种方法
第一种:class test(): ...: num = 0 ...: test1 = test() ...原创 2019-07-16 11:52:56 · 480 阅读 · 0 评论 -
python 列表生成式
a = [ i for i in range(1,18)]In [6]: aOut[6]: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]原创 2019-07-06 15:46:57 · 117 阅读 · 0 评论 -
django 数据库的相关操作
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':'webdb', 'USER':'root', 'PASSWORD':'', 'HOST':'localhost', 'PORT':3306, ...原创 2019-08-13 15:47:22 · 110 阅读 · 0 评论 -
创建django 项目需要配置的地方
1 manage.py#!/usr/bin/env python 改成 #!/usr/bin/env python32 settings.pyINSTALLED_APPS 要添加应用3 settings.pyTEMPLATES 里的模板路径 'DIRS': [os.path.join(BASE_DIR, 'templates')],4 ...原创 2019-08-10 09:49:41 · 128 阅读 · 0 评论 -
scrapy框架的使用
1.创建项目scrapy startproject testspider2 明确目标(items.py)3 制作爬虫程序 xxx/spiders: scrapy genspider 文件名 域名4 处理数据 (pipelines.py)5 配置settings.py 关闭robots协议 添加headers6 运行爬虫项目 scrap...原创 2019-09-23 16:24:49 · 371 阅读 · 0 评论 -
启动elasticsearch
1.启动之前查看jdk版本:java -version (确保jdk为1.8版本)2.启动elasticsearch命令:注意要切换到目录下sh ./bin/elasticsearch注:出现starting与started表示启动成功,出现127.0.0.1:9200表示默认监听端口9200...原创 2019-09-22 16:51:37 · 378 阅读 · 0 评论 -
raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeo
python 安装第三方库,超时报错--Read timed out.Traceback (most recent call last):File "/home/xiaoduc/.pyenv/versions/3.5.0/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 2...原创 2019-09-22 10:39:34 · 3218 阅读 · 0 评论 -
mac selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedri
解决办法ping localhost1. 确保你的webdriver(如safaridriver、phantomjs等)已经下载并解压存放在你的环境变量目录下我的存放目录:/usr/bin/chromedriver检查方式:terminal中输入which chromedriver2.如果仍然不行,请尝试 ping localhost在缺失127.0....原创 2019-09-19 14:38:31 · 3892 阅读 · 1 评论 -
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
是因为没有 安装chromedriver Mac 版本下面是安装步骤有两个下载地址:1、http://chromedriver.storage.googleapis.com/index.html2、https://npm.taobao.org/mirrors/chromedriver/当然,你首先需要查看你的Chrome版本,在浏览器中输入chrome://version/...原创 2019-09-18 14:41:08 · 8025 阅读 · 5 评论 -
phantomjs 截图是空白,源代码也是空白
通常这种情况伴随着qq图片页加载不出来解决办法原创 2019-09-18 13:35:44 · 2138 阅读 · 0 评论 -
json 与 python 数据转换
json.loads json格式-->python数据类型json python对象 字典数组 列表json.dumps() python数据类型 -->json格式python json字典 对象列表 数组元组 数组注意 json.dumps()默认使用ascii编码 ...原创 2019-09-17 09:25:00 · 138 阅读 · 0 评论 -
mangodb 数据库操作
启动 mongo服务 到mongo 目录/usr/local/mongodb/bin 注意 必须在根目录下创建一个data目录 然后在data目录下创建一个db目录 然后 开两个终端窗口一个执行sudo ./mongod 一个执行sudo ./mongo一定要用sudo 不然会报错"""pymongo 回顾"""import pymon...原创 2019-09-09 13:32:55 · 938 阅读 · 0 评论 -
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 8] nodename nor servn
在MySQL Server 已经安装好的情况下, Python 3 使用 pymysql 进行连接数据库操作时,源代码是 db = pymysql.connect("localhost","root","",charset="utf8")解决办法貌似并不规范,我对代码进行了更改,添加了键,如下:# 连接数据库db = pymysql.connect(host=...原创 2019-09-09 09:27:25 · 1242 阅读 · 0 评论 -
AttributeError: 'NoneType' object has no attribute 'encoding'
原因 数据库连接语句哟噗问题db = pymysql.connect("localhost","root","",charset="utf8")注意这里是utf8 而不是utf-8原创 2019-09-09 09:18:56 · 1584 阅读 · 0 评论 -
csv模块使用流程
1 打开csv文件 with open("测试.csv,"a") as f:2 初始化写入对象 writer = csv.writer(f)3 写入数据 writer.writerow(列表)原创 2019-09-05 15:21:31 · 165 阅读 · 0 评论 -
正则表达式
2 正则表达式re 1使用流程 1 创建编译对象 :p=re.compile("正则表达式") 2 对字符串匹配 r=p.match("字符串") 3 获取匹配结果 print(r.group()) 2 常用方法 1 match(s) 字符串开头的第一个,返回对象 2 search(s) ...原创 2019-09-04 16:23:53 · 121 阅读 · 0 评论 -
爬虫请求模块
1 版本python2 : urllib urllib2python3 : 把urllib 和 urllib2合并,urllib.request2 常用方法2.1urllib.request.urlopen("网址") 向网站发起一个请求并获取响应 2.1.1字节流 = response.read() 字符串 = response.read...原创 2019-09-02 16:31:54 · 146 阅读 · 0 评论 -
switchyomega设置浏览器代理
proxy switchomega ->选项 -> 新建情景模式 -> HTTP 127.0.0.1 8888 ->应用选项浏览器右上角图标 -> AID1806 -> 访问百度-->看抓包工具有没有抓到...原创 2019-09-02 15:05:48 · 3042 阅读 · 0 评论 -
fiddler 抓包工具的设置
1、 Tools-->options->HTTPS-> ....from browers only2 connections 设置端口号 8888点击ok 重启原创 2019-09-02 14:59:19 · 122 阅读 · 0 评论 -
python 模块的发布安装代码 的格式
发布2.setup.py 里要写的代码from distutils.core import setup setup(name="aaa",version="1.0",description="bbbb",author="vvvv",py_modules=['TestMsg.sendmsg','TestMsg.recvmsg'])3.构建模块命令python setup...原创 2019-07-06 10:30:01 · 154 阅读 · 0 评论 -
创建生成器的几种方式
方式一: 将列表生成式的中括号改成小括号列表生成式 a = [x*2 for x in range(100000000000)]生成器 a = (x*2 for x in range(100000000000))调用的时候 next(a)方式二:def creatnum(): ...: a,b = 0,1 ...:...原创 2019-07-15 15:15:16 · 760 阅读 · 0 评论 -
append 和 extend 的区别
extend 是把列表中的元素单独拆开与另一个列表中的元素合并到一起append 是把列表直接当作一个整体与另一个列表合并原创 2019-06-24 11:57:38 · 151 阅读 · 0 评论 -
python for循环 和 while 循环
nums = [11,22,33,44,55]for循环for num in nums: print(num)while 循环i=0while i<5:print(num[i])i+=1可以看出 for循环比较简单 while 需要控制次数...原创 2019-06-23 17:26:27 · 202 阅读 · 0 评论 -
ipython 排序
数字类型从小到大 nums.sort()从大到小 nums.sort(reverse=True)逆序 nums.reverse()列表类型列表里有字典 按英文字母排序 infors.sort(key=lambda x:x['name'])...原创 2019-06-26 15:30:36 · 100 阅读 · 0 评论 -
python 可变和不可变类型
不可变类型 数字 ,字符串 ,元组可变类型 列表,字典原创 2019-06-26 14:12:41 · 220 阅读 · 0 评论 -
linux 下打开多个终端
Ctrl+Shift+T 打开多个终端Ctrl+D 关闭终端原创 2019-06-26 11:39:11 · 3910 阅读 · 0 评论 -
Python 字符串查询的几种办法的区别
方法一:find("xxx")如果查到了,返回的是位置,如果查不到,返回的是-1方法二:rfind("xxx")与find 的作用是一样的方法三:index("xxx")如果查到了,返回的是位置,如果查不到,返回的是-错误提示ValueError:substring not found方法四:rindex("xxx")与方法三一样...原创 2019-06-22 14:47:45 · 148 阅读 · 0 评论