ITeye博客

fujinbing的博客

fujinbing · 共 136 篇文章

python 中的内置函数

http://www.cnblogs.com/hongfei/p/3858256.html Built-in Functions [`abs()`](https://docs.python.org/2/library/functions.html#abs "abs") [`divmod()`](https://docs.python.org/2/library/functions.html#divmod "divmod") [`input()`](https://docs.python.org/2/library/functions.html#input "input") [`open()`…

2015-11-12 17:25 · python · 评论(0)

python中的特殊方法的含义

http://blog.csdn.net/fdl19881/article/details/8443893 表 13.4 用来定制类的特殊方法 基本定制型 描述 C.__init__(self[, arg1, ...]) 构造器(带一些可选的参数) C.__new__(self[, arg1, ...]) 构造器(带一些可选的参数);通常用在设置不变数据类型的子类。 C.__del__(self) 解构器 C.__str__(self) 可打印的字符输出;内建 str()及 print 语句 C.__repr__(self) 运行时的字符串输出;内建 repr() 和‘‘ 操作符 C.__u…

2015-11-12 16:57 · python · 评论(0)

mapreduce streaming

stream 中mapper若有空格,必须用引号引起来,否则报错 -mapper "python stream_video.py" File "<stdin>", line 1 SyntaxError: Non-ASCII character '\xa3' in file <stdin> on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

2014-11-05 11:54 · linux 工具包 · 评论(0)

程序接口

pragram_interface_1(http://hb2014.px.teacher.com.cn/home/student/1334/course/learn/12/6/1024)

2014-07-24 09:57 · 话 · 评论(0)

python升级

1 [root@local_redhat ~]# python 2 Python 2.4.3 (#1, May 5 2011, 16:39:10) 3 [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 4 Type "help", "copyright", "credits" or "license" for more information. 5 >;>> 6 [root@local_redhat ~]# 下载新版本的python 1 [root@local_redhat ~]# wget http://python.org/ftp/pyt…

2013-10-24 11:25 · 评论(0)

stack溢出 ** stack smashing detected ***: ./a.out terminated

该类错误是修改了返回指针,一般是由于 1. 数组越界赋值。(数组没有边界检查)int a[8]; a[8],a[9],a[-1]。。都能正常编译,连接,运行时可能出错。 2.使用 strcpy等不安全(不带长度检测的函数),char a[1], char *b="aaa"; strcpy(a,b); 局部变量(函数内的变量)存在栈中,应为栈是先下(低地址)生长的,故 函数返回指针 要比局部变量的地址高,像类似的a[8]之类的就有机会访问到 函数返回指针了。 首先运行第一个程序: #include “string.h” void fun1(const char *str) { char buf…

2013-05-10 13:08 · c语言学习 · 评论(0)

C++中的内部链接和外部链接

c++中的内部连接与外部连接 Apr 22nd, 2007 by king 一.在学习内部连接与外部连接之前,必须先弄清楚几个概念: 1.声明 一个声明将一个名称引入一个作用域。在c++中,在一个作用域中重复一个声明是合法的。 以下都是声明: int foo(int,int); //函数前置声明 typedef int Int; //typedef 声明 class bar; //类前置声明 extern int g_var; //外部引用声明 friend test; //友员声明 using std::cout; //名字空间引用声明 在同一作用域中可以多次重复以上声明,但是有两种声明是…

2013-04-20 15:23 · c++ · 评论(0)

c++无类型参数模板(non-type template parameter) 与 无具名空间 static

无类型的模板参数: C++的template可以传入普通的参数,和平时使用普通的函数参数有点相似,但又有很大的不同。 这种形式的模板一般是用来初始化类的数组成员的大小例如下面有的代码: template<int size> class CTest { int m_data[size]; }; void main() { CTest<10> obj;// 将obj对象的成员 数值m_data大小初始为10 ,是不是很简单? } 用整型来作为无类型模板参数使用起来确实simple,那么换其他类型试试? 收集了一点资料稍微整理了下,看看下面资料怎么说的: a non-type template-p…

2013-04-20 15:19 · c++ · 评论(0)

dynamic_cast static_cast

c++ 中定义了一些类型转换函数,如:static_cast,dynamic_cast等。 一、 static_cast 用在如下四种情况。 1.类的层次结构中,基类与派生类之间指针与引用的转换 1.) 派生类 =>基类 是安全的,应为派生类包含基类部分。 2.) 基类 =>派生类,是不安全的,需要程序员保证。 2.用于基本数据类型之间的转换,如 int转为char, int 转为enum,这种转换也需要程序员来保证。 3.把空指针 =》其他类型空指针 注意:static_cast不能转换掉expression的const、volatile、或者__unaligned属性 二、dynamic…

2013-02-28 16:36 · c++ · 评论(0)

关于ubuntu启动项

如果在 /etc/init.d 中加入一个 script,还须要制作相关的 link 在 /etc/rc*.d 中。K 开头是 kill , S 开头是 start , 数字顺序代表启动的顺序。(SysV) update-rc.d 可以帮你的忙。 例: 在 /etc/init.d 中建立一个叫作 zope 的 script , 然后 update-rc.d zope defaults 就会产生以下链結:: Adding system startup for /etc/init.d/zope ... /etc/rc0.d/K20zope -> ../init.d/zope /etc/rc1.d…

2012-03-09 10:35 · linux 工具包 · 评论(0)

apache+php

apache 若不设置 DirectoryIndex index.html index.php 会导致如下错误:Directory index forbidden by Options directive: /var/www/test php +apache 有时对date方法会有错误 加入如下即好使 <?php date_default_timezone_set("PRC"); ?>

2012-03-07 19:09 · linux 工具包 · 评论(0)

python使用pdb调试程序

Python自带了一个调试器叫pdb,和Gnu的gbd类似。下面用一个简单的程序来演示pdb的功能。程序代码如下: #!/usr/bin/python import pdb a = "aaa" import pdb pdb.set_trace() b = "bbb" c = "ccc" final = a + b + c print final pdb的命令 1.查看代码上下文,l(小写L) > /home/jking/test/python/tt.py(6)<module>() -> b = "bbb" (Pdb) l 1 #!/usr/bin/python 2 3 import pdb …

2012-02-06 12:25 · linux 工具包 · 评论(0)

apache 的跳转(Rewrite) 代理(Proxy) 和重定向(ProxyPass)

#RewriteEngine on #RewriteRule ^(.*)$ http://ops.goso.cn #ProxyRequests On ProxyPass /show.php http://192.168.10.27/show.php

2012-02-02 13:18 · 网站 · 评论(0)

指针与数组在结构体中的差别

在结构体中,数组和指针最大的的区别为: 数组将信息存在结构体所占有的内存中 , 而指针是将信息的首地址保存在结构体所占有的内存中 引申:结构体中的指针的默认初始值是随机的。 而结构体中的数组

2012-01-19 13:49 · c语言学习 · 评论(0)

cgi 不能访问外部资源,cannot create directory ==>超级安全的selinux

今天,做一个监控脚本,但总是不能成功创建目录, 经过认真检查,权限没有问题。 经过反复测试,/tmp目录下有读写操作,其余均不能。 反复思考,最终定位在selinux 执行:getenforce enforcing 执行:cat /etc/selinux/config SELINUX=enforcing SELINUXTYPE=targeted SETLOCALDEFS=0 找到问题。 修改cat /etc/selinux/config SELINUX=disabled 执行:setenforce 0 成功。

2011-09-27 15:30 · linux 工具包 · 评论(1)