随笔 - 203  文章 - 11  评论 - 15  阅读 - 81万

随笔分类 -  python

1 2 3 下一页
win7(64bit)+python3.5+pyinstaller3.2安装和测试
摘要:最近因为做项目需要,需要在win7中安装pyinstaller用于将.py文件生成脱离python平台的可执行程序 .exe文件。 安装步骤 第一步:安装python3.5 [下载python3.5的安装包列表] (https://www.python.org/ftp/python/3.5.0/) 阅读全文
posted @ 2017-02-13 09:35 mingaixin 阅读(5905) 评论(0) 推荐(0) 编辑
WARNING: Can not get binary dependencies for file...
摘要:环境: window7 64bit python 3.5 pyinstaller 3.2 用pyinstaller 将python文件打包成exe文件的过程中,出现了如下的错误 通过google,找到最终的解决方案,原因是pyinstaller 3.2有bug,目前开发版本的pyinstaller解 阅读全文
posted @ 2017-02-10 16:00 mingaixin 阅读(1463) 评论(0) 推荐(0) 编辑
mac中安装wxpython
摘要:一、简介 wxPython是Python语言的一套优秀的GUI图形库,允许Python程序员很方便的创建完整的、功能键全的GUI用户界面。 wxPython是作为优秀的跨平台GUI库wxWidgets的Python封装和Python模块的方式提供给用户的。 二、安装 1、安装python3.5.2 阅读全文
posted @ 2017-01-19 11:18 mingaixin 阅读(920) 评论(0) 推荐(0) 编辑
mac上Python多版本共存(python2.7.10和python3.5.0)
摘要:本文的实现目标是在mac上安装一个python3.5.0的版本,跟当前系统自带的python2.7.10共存. 查看当前版本号 安装配置Python版本管理器pyenv 1. 安装pyenv 安装过程中,遇到一个一个问题 "Error: parent directory is world writa 阅读全文
posted @ 2017-01-18 11:01 mingaixin 阅读(8111) 评论(0) 推荐(0) 编辑
pyenv BUILD FAILED解决方法
摘要:在本机mac上安装pyenv安装成功后,用pyenv来安装python 3.5.0又出现了如下的问题: 解决方法:使用如下语句安装即可解决问题 参考资料 "pyenv BUILD FAILED解决方法" 阅读全文
posted @ 2017-01-18 10:30 mingaixin 阅读(1695) 评论(0) 推荐(0) 编辑
Error: parent directory is world writable but not sticky
摘要:在本地安装pyenv的时候,出现了如下的报错: ➜ brew install pyenv == Downloading https://github.com/yyuu/pyenv/archive/v20160310.tar.gz Already downloaded: /Library/Caches 阅读全文
posted @ 2017-01-18 09:15 mingaixin 阅读(1056) 评论(0) 推荐(0) 编辑
爬取千万淘宝商品的python脚本
摘要:import timeimport leveldbfrom urllib.parse import quote_plus import reimport jsonimport itertoolsimport sysimport requestsfrom queue import Queuefrom ... 阅读全文
posted @ 2015-03-12 14:18 mingaixin 阅读(8865) 评论(0) 推荐(0) 编辑
监控程序执行时间并将其写入日志的脚本
摘要:# /usr/bin/python# -*- coding:utf-8 -*-from time import timedef logged(when): def log(f,*args,**kargs): print ''' called: functions:%s args: %r kargs: %r ''' % (f,args,kargs) def pre_logged(f): ... 阅读全文
posted @ 2013-03-06 14:35 mingaixin 阅读(536) 评论(0) 推荐(0) 编辑
python的加密模块(md5,sha,crypt)学习
摘要:md5(Message-Digest Algorithm 5) 模块用于计算信息密文(信息摘要),得出一个128位的密文。sha模块跟md5相似,但生成的是160位的签名。使用方法是相同的。如下实例是使用md5的:# /usr/bin/python# -*- coding:utf-8 -*-import base64try: import hashlib hash = hashlib.md5()except ImportError: # for Python << 2.5 import md5 hash = md5.new()hash.update('spam,s... 阅读全文
posted @ 2013-02-20 19:41 mingaixin 阅读(19975) 评论(0) 推荐(1) 编辑
DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5的解决办法
摘要:今天在学习python的md5模块的时候,做练习,遇到DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5的警告;# /usr/bin/python# -*- coding:utf-8 -*-import md5hash = md5.new()hash.update('spam,spam,and egges')print repr(hash.digest())执行结果为:解决办法:# /usr/bin/python# -*- coding:utf-8 -*-try: im 阅读全文
posted @ 2013-02-20 16:09 mingaixin 阅读(5162) 评论(0) 推荐(0) 编辑
python的keyword模块
摘要:python的keywrod 模块很简单。Help on module keyword:NAME keyword - Keywords (from "graminit.c")FILE /usr/lib64/python2.6/keyword.pyDESCRIPTION This file is automatically generated; please don't muck it up! To update the symbols in this file, 'cd' to the top directory of the python sour 阅读全文
posted @ 2013-02-04 14:46 mingaixin 阅读(5949) 评论(0) 推荐(0) 编辑
python脚本自动发邮件功能
摘要:最近给项目加监控,用python写了一个脚本,在出错的时候自动发邮件通知的功能。代码如下#! /usr/bin/python# -*- coding: utf-8 -*- from smtplib import SMTPSMTPSVR='mail.xxx.com' #smtp服务器域名origHdrs=['From:monitor@xxx.com','To:cax@xxx.com,monitor@xxx.com','Subject:视频出现异常'] #定义邮件头origBody=['xxx','yyy 阅读全文
posted @ 2013-01-31 15:54 mingaixin 阅读(3768) 评论(0) 推荐(0) 编辑
python多重继承新算法C3
摘要:mro即 method resolution order (方法解释顺序),主要用于在多继承时判断属性的路径(来自于哪个类)。在python2.2版本中,算法基本思想是根据每个祖先类的继承结构,编译出一张列表,包括搜索到的类,按策略删除重复的。但是,在维护单调性方面失败过(顺序保存),所以从2.3版本,采用了新算法C3。为什么采用C3算法C3算法最早被提出是用于Lisp的,应用在Python中是为了解决原来基于深度优先搜索算法不满足本地优先级,和单调性的问题。本地优先级:指声明时父类的顺序,比如C(A,B),如果访问C类对象属性时,应该根据声明顺序,优先查找A类,然后再查找B类。单调性:如果在 阅读全文
posted @ 2013-01-31 15:41 mingaixin 阅读(5801) 评论(1) 推荐(2) 编辑
python的多重继承
摘要:python和C++一样,支持多继承。概念虽然容易,但是困难的工作是如果子类调用一个自身没有定义的属性,它是按照何种顺序去到父类寻找呢,尤其是众多父类中有多个都包含该同名属性。对经典类和新式类来说,属性的查找顺序是不同的。现在我们分别看一下经典类和新式类两种不同的表现:经典类:#! /usr/bin/python# -*- coding:utf-8 -*-class P1(): def foo(self): print 'p1-foo'class P2(): def foo(self): print 'p2-foo' def bar(self): ... 阅读全文
posted @ 2013-01-31 14:55 mingaixin 阅读(8712) 评论(0) 推荐(3) 编辑
python垃圾回收机制
摘要:转载自: http://my.oschina.net/hebianxizao/blog/57367现在的高级语言如java,c#等,都采用了垃圾收集机制,而不再是c,c++里用户自己管理维护内存的方式。自己管理内存极其自由,可以任意申请内存,但如同一把双刃剑,为大量内存泄露,悬空指针等bug埋下隐患。 对于一个字符串、列表、类甚至数值都是对象,且定位简单易用的语言,自然不会让用户去处理如何分配回收内存的问题。 python里也同java一样采用了垃圾收集机制,不过不一样的是,python采用的是引用计数机制为主,标记-清除和分代收集两种机制为辅的策略。 引用计数机制:python里每一个... 阅读全文
posted @ 2013-01-31 11:18 mingaixin 编辑
python中的自省
摘要:python中的自省,介绍一下几个重要的函数:dir函数,传入的参数是对象,返回该对象的所有属性和函数列表:>>> import string>>> dir(string)['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_float', 阅读全文
posted @ 2013-01-29 11:32 mingaixin 阅读(467) 评论(0) 推荐(0) 编辑
python中的反射
摘要:python是如何体现反射的:globals()这个函数返回一个map,这个map的key是全局范围内对象的名字,value是该对象的实例。在不导入任何module下,执行globals()的结果如下:>>> globals(){'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None, '__package__': None}在导入sys后,可以 阅读全文
posted @ 2013-01-29 11:21 mingaixin 阅读(635) 评论(0) 推荐(0) 编辑
python 实现单例模式
摘要:class Singleton(object): _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs) return cls._instance if __name__ == '__main__': s1=Singleton() s2=Singleton() if(i... 阅读全文
posted @ 2013-01-29 10:43 mingaixin 阅读(476) 评论(1) 推荐(0) 编辑
Python容易混淆的地方
摘要:转载自: http://blog.csdn.net/carolzhang8406/article/details/6855525每门编程语言都有易混淆的部分,下面列举出一些Python的易混淆知识点。== 和 is 的区别在Python中,”==” 操作符测试值的相等性; “is”表达式测试对象的一致性,即是否指向同一个对象。list1 = [1,('a',3)]list2 = [1,('a',3)]list1 == list2, list1 is list2 #(True,False)说明:list1和list2通过了”==”测试 (他们的值相等,因为它们的所 阅读全文
posted @ 2013-01-28 17:23 mingaixin 阅读(584) 评论(0) 推荐(0) 编辑
python __init__和__new__之间的区别
摘要:转载自 http://blog.csdn.net/carolzhang8406/article/details/68560561 如果在类中同时定义了__init__和__new__,在创建对象的时候会有优先使用__new__如class A(object): def __init__(self): print("in init") def __new__(self): print("in new") A()2new方法会返回所构造的对象,init则不会,在使用new返回对象的时候会隐式调用init函数。new函数必须以cls作为第一个参数,而init则 阅读全文
posted @ 2013-01-28 17:21 mingaixin 阅读(3747) 评论(1) 推荐(0) 编辑

1 2 3 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示