摘要: # -*- coding:utf-8 -*-import threadingfrom random import Randomimport timeclass Producer(threading.Thread): def __init__(self, products, lock): threading.Thread.__init__(self) self.__products = products self.__lock = lock def run(self): _random = Random(100) while True: if len(self.__products) > 阅读全文
posted @ 2011-03-04 22:49 steven zhao 阅读(250) 评论(0) 推荐(0) 编辑
摘要: python什么时候处于debug模式呢?python启动时加上-o选项,或者设置了PYTHONOPTIMIZE=x,__debug__将为True;不加-o时,__debug__为False;__file__的使用在程序中使用__file__时,__file__代表本文件的路径;当程序在别的目录时,也会跟着变;但是当程序用py2exe等工具打包成一个exe时,__file__就不再存在了,程序会以异常结束。别人的解释:如何编译?使用py_compile可以编译py文件为pyc、pyo如果不要__doc__(如在正式版本中),可以加上python的优化选项-oo 阅读全文
posted @ 2011-02-16 22:36 steven zhao 阅读(1118) 评论(0) 推荐(1) 编辑
摘要: useradd-c comment给账户添加注释信息,说明此账户的是干什么用的,有些linux上把它作为用户的全名-d dir 为用户指定主目录;如果不指定,将使用 /etc/default/useradd中HOME指定的路径建立主目录,主目录名称为用户名-m 此选项会检查-d指定的主目录是否存在,如果不存在则创建它;如果没有指定主目录,则以/etc/default/useradd中HOME的值创... 阅读全文
posted @ 2010-01-21 20:53 steven zhao 阅读(5474) 评论(0) 推荐(0) 编辑
摘要: 发现好久不用shell之后,语法都生疏了;今天写个小游戏练练手。#!/bin/bash#产生一个100到999的随机数NUM=`echo ${RANDOM}|cut -c-3`#记下猜测的次数count=0while :do echo -n "Type a number:" read num #判断输入数否为数字 is_num=`echo ${num}|grep ^[0-9]*$` if [ ... 阅读全文
posted @ 2010-01-08 14:31 steven zhao 阅读(507) 评论(0) 推荐(1) 编辑
摘要: Linux中有几个特殊的文件:crw-rw-rw- 1   root root  1, 3   2009-11-26 21:23   null crw-rw-rw- 1   root root   1, 8   2009-11-26 21:23   random crw-r--r-- 1   root root   1, 9   2009-11-24 04:51   urandom c... 阅读全文
posted @ 2009-12-30 21:16 steven zhao 阅读(324) 评论(0) 推荐(0) 编辑