免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库

动态

2016-06-21

  • maple412 发表了新话题 2016-06-21 10:08
    ubuntu下安装python模块psutil失败
    提示错误如下:请各位大神看下是什么原因,该如何解决,谢谢 running install running build running build_py running build_ext building '_psutil_linu ...

2016-06-15

  • maple412 发表了新话题 2016-06-15 21:31
    ubuntu下安装python模块psutil失败
    提示错误如下:请各位大神看下是什么原因,该如何解决,谢谢 running install running build running build_py running build_ext building '_psutil_linu ...

2016-06-14

  • maple412 发表了新话题 2016-06-14 22:03
    ubuntu下安装python模块psutil失败
    提示错误如下:请各位大神看下是什么原因,该如何解决,谢谢 running install running build running build_py running build_ext building '_psutil_linu ...

2016-05-22

  • maple412 发表了新话题 2016-05-22 15:01
    文件的权限问题
    新建一个文件test.txt,用户和群组分别属于 zhf:zhf 新增一个群组 zhf_test, 并将test.txt的群组通过chgrp zhf_test test.txt命令改成了zhf_test 此时文件的用 ...

2016-04-06

  • maple412 发表了新话题 2016-04-06 21:56
    IFS的设置
    echo $IFS的时候显示为空格 在sh文件里面重新设置IFS: set IFS=':' echo $IFS 仍然为空格,没有生效,请问是什么原因

2016-03-08

  • maple412 发表了新话题 2016-03-08 22:13
    邮箱内容解析失败
    def Parse_email(mailserver,mailuser,mailpasswd): print 'Parse_email is working:' server=login_email(mailserver,mailuser,mailpasswd) m ...

2016-03-03

  • maple412 发表了新话题 2016-03-03 21:44
    poplib获取邮件失败
    import poplib,sys mailserver='mail.163.com' mailuser='XXX@163.com' mailpasswd='XXXX' print 'Connecting:' server=poplib.POP3(mailserver) ...

2016-02-16

  • maple412 发表了新话题 2016-02-16 20:51
    关于构造函数
    class human{ int age; human(){ age=1; System.out.println("Human"); } } class boy extends human{ boy(){ System.out.println("boy ...

2015-12-23

  • maple412 发表了新话题 2015-12-23 22:26
    使用xlutils.copy的疑问
    对已存在的excel文档进行添加数据。使用如下方法, 但是最终保存下来的文件格式和源文件格式不一样,还需要自己调整 wb=copy() ws=wb.get_sheet() wb.save('o ...

2015-12-17

  • maple412 发表了新话题 2015-12-17 22:43
    使用BeautifulSoup中的疑问
    使用BeautifulSoup抓取网页内容,然后利用findAll功能查找class="nav customfield_10130"的项 soup=BeautifulSoup(result.read()) contents=soup.findAll(cl ...

2015-12-11

2015-11-28

2015-11-23

  • maple412 发表了新话题 2015-11-23 15:22
    cx_freeze打包python问题
    使用的是python2.7,用cx_freeze打包后,在exe的操作界面中无法输入中文,请问有什么解决方法吗?另外打包后是否可以识别中文路径?

2015-11-10

  • maple412 发表了新话题 2015-11-10 21:32
    python网络编程问题
    刚开始学python网络编程。在windows上分别建立server.py和client.py文件 client.py: import socket import time sock=socket.socket(socket.AF_INET,socket. ...

2015-11-09

  • maple412 发表了新话题 2015-11-09 22:02
    python操作excel的疑问
    import xlrd import xlwt from xlutils.copy import copy wb=xlrd.open_workbook(r'e:/py_prj/test.xls',formatting_info=True) print wb newwb=copy(w ...

2015-10-19

  • maple412 发表了新话题 2015-10-19 21:45
    使用nltk报错
    想通过nltk中的clean_html功能来清除html内容 import nltk,re,pprint import urllib2 html='‘ /论坛发不了html链接/ h=urllib2.urlopen(html) c=h.rea ...

2015-10-01

  • maple412 发表了新话题 2015-10-01 21:35
    文本提取
    文本如下 [Time stamp] 828382368 [Time stamp] 10640418 143> 01 00000001 ..........................ID:0x1 (1) [Time stamp] 82838237 ...

2015-09-22

2015-09-11

  • maple412 发表了新话题 2015-09-11 22:10
    提取网页的内容
    temp=''' 乐观主义这一切向前看。 ''' 需要把 后面的"乐观主义者向前看"提取出来, python代码如下 import re content=re.findall(' ...
  • maple412 发表了新话题 2015-09-11 22:10
    提取网页的内容
    temp=''' 乐观主义这一切向前看。 ''' 需要把 后面的"乐观主义者向前看"提取出来, python代码如下 import re content=re.findall(' ...

2015-08-18

2015-07-18

2015-07-09

2015-07-06

2015-07-03

2015-06-30

  • maple412 发表了新话题 2015-06-30 20:02
    python读取xml文件问题
    解析XML文档 doc=minidom.parse(r'F:\cygwin\tmp\zh\test\test.XML') child=doc.childNodes child1=child.childNodes print child1 但是却报错:A ...

2015-06-29

  • maple412 发表了新话题 2015-06-29 09:40
    解析XML文档的问题
    XML文档如下: 1 逐行解析每行的数据 BEGIN{ FS="\n" } //,//{ print $2 } 但是得到的结果确是空的,难道FS设置得不对?

2015-06-27

2015-06-23

2015-06-22

2015-06-17

  • maple412 发表了新话题 2015-06-17 10:57
    关于类的使用
    class ringbuffer(): def __init__(self,size_max): self.max=size_max self.data=[] class __full(): def append(slef,x ...

2015-06-16

2015-06-15

2015-06-11

2015-06-07

2015-05-29

  • maple412 发表了新话题 2015-05-29 11:14
    getattr的疑问
    getattr的描述如下: Return the value of the named attributed of object. name must be a string. If the string is the name of one of the object’s att ...

2015-05-18

  • maple412 发表了新话题 2015-05-18 17:32
    正则表达式的疑问
    inp=re.compile(r"(\d+\.?\d*)([-+/*])") tape_line="1.3+4.5+6.7" print inp.match(tape_line).groups() ('1.3', '+') 按照预期,应该输出('1. ...

2015-05-12

2015-04-30

2015-04-29

2015-04-25

  • maple412 发表了新话题 2015-04-25 14:53
    __setattr__的用法
    class circle(): def __init__(self): self.width=0 self.height=0 def __setattr__(self,name,value): if name == 'siz ...

2015-04-02

  • maple412 发表了新话题 2015-04-02 11:32
    替换失败
    echo ${ /tmp/zhf/test/next.txt#/*/} 提示替换失败:bad substitution

2015-03-26

  • maple412 发表了新话题 2015-03-26 14:22
    关于while循环的问题
    如下shell脚本。但是输出没有任何内容 saveift=$IFS IFS=: while read name depar id do emp_name=$name emp_depar=$depar emp_id=$id echo $emp_name ...

2015-03-20

  • maple412 发表了新话题 2015-03-20 10:33
    grep使用疑问
    先查找本目录下所有的文件,然后通过grep过滤出sh文件,但执行无任何结果。 find . -type p | xargs grep "*.sh" 只能改成如下方式 find . -name "*.sh" ...

2015-03-02

  • maple412 发表了新话题 2015-03-02 21:41
    正则表达式疑问
    正则表达式如下: address=re.compile( (?p) ([\w.,]+\s+]*[\w.,]+) ) 不明白这个?p代表什么 还有类似的?p

2015-02-27

  • maple412 发表了新话题 2015-02-27 21:23
    关于正则表达式的疑问
    import re text='This is some text -- with punction' regex=re.compile(r'(\bt\w+)\W+(\w+)') print 'pattern :',regex.pattern match=regex.se ...

2015-02-26

  • maple412 发表了新话题 2015-02-26 11:13
    mysql的操作界面中如何输入中文
    目前没找到方法去做输入法切换,如果需要打 中文的话只有拷贝进去,例如: insert into work_info values(1,'张三','M',18,'北京市海淀区','1234567') ...

2015-01-28

2015-01-27

  • maple412 发表了新话题 2015-01-27 22:12
    python项目开发
    对python语法都比较理解了,想问下一般都用python做什么开发,用到什么工具,目前都是在python shell下面写一些程序,想学习下相应的项目开发。 主要感兴趣的是 ...
  • maple412 发表了新话题 2015-01-27 17:54
    正则表达式匹配
    想分别匹配数组和'-',表达式如下 parse=re.compile('(\d+)|(-)') parse.match('123-456').groups() 但是匹配出来的只有123,没有-

2015-01-11

  • maple412 发表了新话题 2015-01-11 14:23
    FS与OFS的区别
    文本文件: mona 70 77 85 83 70 john 85 92 78 94 100 BEGIN{ FS="\t" } { print NF,NR } 得到的结果是: $ awk -f 1.awk 1.txt 1 1 1 2 改 ...

2015-01-08

2015-01-07

  • maple412 发表了新话题 2015-01-07 15:36
    正则表达是的疑问
    这个时候的\是转义\n,所以输出\n >>> a="abc\\ncd" >>> print a abc\ncd 但是如果是下面的这种形式的话,输出如下,为啥abc后面还带一个\n并且分 ...

2014-12-31

  • maple412 发表了新话题 2014-12-31 11:36
    关于字典
    统计字符串中各个字符的个数,代码如下 def countWords(strLine): count={'alpha':0,'space':0,'digit':0,'others':0} length=len(strLine) ...

2014-12-30

  • maple412 发表了新话题 2014-12-30 15:21
    解析XML数据失败
    XML文件: python代码: from xml.sax.handler import ContentHandler import xml.sax import sys class textHandler(ContentHandler): de ...

2014-12-18

  • maple412 发表了新话题 2014-12-18 11:21
    正则表达式出错
    ret=re.compile(r'(\d+\.?\d*),([-+\*])') #根据数字或者运算符号来进行匹配 input='1+2+3' ret.match(input) 但最后ret.match的结果为None,各位看 ...

2014-12-17

  • maple412 发表了新话题 2014-12-17 10:37
    import win32con报错
    需要使用模块来处理word文档,调用win32con和win32api的时候报错,各位看看该如何解决呢 >>> import win32con Traceback (most recent call last): File ...

2014-12-15

  • maple412 发表了新话题 2014-12-15 11:38
    yield的使用疑问
    def counter(start=0): count=start while True: val=(yield count) count+=1 执行如下: >>> c.next() 5 >>> c.next() 6 ...

2014-11-23

  • maple412 发表了新话题 2014-11-23 20:24
    sed命令中N
    文本如下: Consult Section 3.1 in the Owner and Operator Guide for a description of the tape drives available on your system. 想要将Owner and O ...

2014-11-15

  • maple412 发表了新话题 2014-11-15 22:58
    sed命令使用疑问
    原始文件 Column1&Column2&Column3&Column4 想要达到如下效果: Column1&Column2 Column3&Column4 sed脚本: s/&/\/2 运行报错 改成下面就可以了,这 ...

2014-11-10

  • maple412 发表了新话题 2014-11-10 22:13
    如何删除同类型的日志文件
    在var/log文件夹下面存在大量zmd-messages.log.xxxx-xx-xx(最后几位为日期)的文件,想把这一类文件全部删除 使用如下命令删除的话会导致误删除,比如xorg.0.l ...

2014-11-07

  • maple412 发表了新话题 2014-11-07 10:32
    迭代的用法
    class anyiter(): def __init__(self,data,safe=False): self.safe=safe self.iter=iter(data) def __iter__(self): retu ...

2014-11-05

  • maple412 发表了新话题 2014-11-05 23:02
    crontab命令请教
    新建一个文件cronfile01, 内容如下:每分钟输出一个haha到test.txt文件中 */1 * * * * echo "haha" > /home/zhf/test/test.txt 执行命令: crontab cron ...
  • maple412 发表了新话题 2014-11-05 14:45
    类中的函数修饰符疑问
    class TestStaticMethod: @staticmethod def foo(): print 'calling static method foo()' 这段代码中staticmethod中代表什么意义,对这种修饰符在函数中 ...

2014-11-03

  • maple412 发表了新话题 2014-11-03 17:46
    yield的使用问题
    通过下面的代码打印随机数 from random import randint def randGen(alist): while len(alist) > 0: yield alist.pop(randint(0,len(alist))) ...

2014-10-27

  • maple412 发表了新话题 2014-10-27 11:41
    关于awk中分隔符的疑问
    文文件 192.168.0.1 (maple.com) 192.168.0.1 (xx.com) 想单独提取 (maple.com)和(xx.com)字段。如下脚本能够提取出来,没看懂[()]这个分隔符 ...

2014-10-25

2014-10-10

  • maple412 发表了新话题 2014-10-10 10:25
    awk中match的应用
    match函数包含两个系统变量,RSTART和RLENGTH,但是match函数只和第一次出现的子串匹配 比如下面的字符串: Every Now and Then 想要匹配所有的大写字母。然后 ...

2014-10-09

  • maple412 发表了新话题 2014-10-09 10:14
    awk使用疑问
    BEGIN{ sizeofarray=split("a-b-c",number,"-") } { print sizeofarray } 这样无法打印出sizeofarray,改成如下形式后可以正常打印 BEGIN{ ...

2014-09-23

  • maple412 发表了新话题 2014-09-23 16:41
    sed中跳转命令的用法
    文本文件 1 2 11 22 111 222 sed脚本: /11/b end s/22/33/ :end s/2\{3\}/333/ 在匹配了11之后,应该跳转到:end去执行s/2\{3\}/333/, s/22/33/ ...

2014-09-10

  • maple412 发表了新话题 2014-09-10 21:32
    sed命令中关于p的用法
    我理解p是打印和模式空间匹配的内容 下面的这个测试文件,想打印出20010这一行的内容 20010 135 20011 136 20012 137 20013 133 20014 138 20015 1 ...

2014-07-02

  • maple412 发表了新话题 2014-07-02 17:23
    sed命令中n和N的区别
    文本文件内容如下 .H1 Consult Section 3.1 in the Owner and Operator sed脚本: /^.H/{ n /^$/d } 该脚本会将.H1后面的一行空格删除掉 但如果 ...

2014-06-24

  • maple412 发表了新话题 2014-06-24 22:53
    awk中getline的用法
    file=/tmp/zhf/c_test/test.c awk ' BEGIN{ FS=" " getline < "$file" print $1 } ' 如下将路径复制给file,并利用getline命令读入该文件并打印第 ...
  • maple412 发表了新话题 2014-06-24 22:22
    shell脚本中``的作用
    写了个简单的shell脚本 cd /tmp/zhf/test name = `ls` echo $name 在目标路径下执行ls命令并将结果传递给name变量并输出,提示name=`ls`命令出错

2014-06-11

  • maple412 发表了新话题 2014-06-11 10:56
    find命令使用
    需要将/tmp/zhf路径下各文件中包含的.mrf文件统一拷贝到一个目录下面 find /tmp/zhf -name "*.mrf" -depth -exev mv "*.mrf" /tmp/zhf/pr_test {} \; ...

2014-06-06

2014-05-28

2014-05-26

  • maple412 发表了新话题 2014-05-26 21:27
    tmpfile的疑问
    不太理解下面这个语句的作用 TMP=${TMPDIR:/tmp} 系统上执行echo $TMP是空的,echo $TMPDIR也是空的

2014-05-02

  • maple412 发表了新话题 2014-05-02 11:08
    awk的一个使用疑问
    代码如下: awk ' BEGIN{ printf("enter the number:") } $1 ~/^[0-9]/ { number=$1 if ( number == 0) fact=1 else fact=2 } END { print ...

2014-04-24

  • maple412 发表了新话题 2014-04-24 19:27
    awk中嵌入条件判断式疑问
    awk -F, '{if($1==z1) print $1}' 8.txt 执行出来没有任何打印, 但是用下面的方法就可以打印出来 awk -F, '{if($1~/z1/) print $1}' 8.txt

2014-04-20

2014-04-17

2014-04-16

  • maple412 发表了新话题 2014-04-16 22:31
    cygwin上执行gcc出错
    编译文件的时候出现如下错误,请看下什么原因,GCC相关的文件都已经装好了 $ gcc -o simple_write.c gcc: fatal error: no input files compilation terminat ...
  • maple412 发表了新话题 2014-04-16 11:28
    新手求助
    想通过输入路径然后执行cd命令进入到目录,最后查看该目录下的所有文件 read -p "Please input the directory:" dir cd $dir | ls -al 但是执行结果永远是 ...

2014-04-15

  • maple412 发表了新话题 2014-04-15 17:53
    sed的疑问
    在每个字符后面添加一个换行符,使得每行出现一个字符 echo "abc" | sed 's/[^\n]/&\n/g' 对这句命令不是很明白。[^\n]这个是匹配行首的,&\n是行尾 ...

2014-04-14

  • maple412 发表了新话题 2014-04-14 21:55
    linux初学者的程序疑问
    在cygwin下执行如下程序: #include #include int main() { if ((write(1,"here is some data\n",1)!=1 write(2,"A write error has occur ...

2014-04-10

  • maple412 发表了新话题 2014-04-10 11:16
    关于shell学习
    学习SHELL有段时间了,对各种命令都有了个基本的了解,想更深入的学习下shell在运维管理上的应用,有哪些好的资料呢?或者有大牛写的shell脚本没,可以参考学习下 ...

2014-04-07

2014-04-04