Python论坛  - 讨论区

标题:[python-chinese] How to start program by Python, and excut e the program's command?

2006年09月12日 星期二 11:47

xhsoldier xhsoldier在163.com
星期二 九月 12 11:47:10 HKT 2006

ée¡ëÞ¯*'xŒžÛh²Ö«µªk¢
ښØ^¦º ­©§yçm¡·¬zÛayé'™éí½ªâj{_Š»-ºÈ§€ü­†‰ÚÛ-j»b¶Ø^žë"ž
r¶'¶‡±rë^¶œ¢išÚk¢øyÖò¶©®ˆ+jaèÂÚ¢Øb°†¦ºÈ§‚)©¢»h²‹Åç/zÊ&z;–«jËhv‹aŠÆ§v+p¢¹,Š×h²Ö«¶Æî·Z´ŒžØ¬²Ú+zØ^¢ëiºØ§iø¥{b•ë¬Šx)ÊØhž'žz-±çšŸ*.¶›­¶§’ÁÓ0µ.m§ÿéÊØhÉÿ¦*^®f¢—úr¶'r§zÇ¿jÛZržžÛ?ÛM:ÓÝvÿ]Ÿñý¹oö­µ§!™éí†Ù¥

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 12:09

Qiangning Hong hongqn在gmail.com
星期二 九月 12 12:09:49 HKT 2006

On 9/12/06, xhsoldier <xhsoldier在163.com> wrote:
> I am using
> import os
> os.execve(some paras) to do this, and it works, it do starts
> but what I want is: store the output in a file while using python i can not
> see any output

see subprocess module pls. good luck.

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 12:20

zhangpf zhangpf在ichaier.com
星期二 九月 12 12:20:32 HKT 2006

有一个二进制的bit文件,想把他的内容转化为16进制的文本文件:

fh = open('EBIKE_73H.BIN', 'rb')
str = fh.read()
这个读到str里的到底是什么格式呢??

在网上查了查好像要用struct.unpack转
搞了半天不得要领

那位指点一下

我想把str里的东西以16进制的形式print出来就可以了,怎么做呢?

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 21:27

kongkongxiangbo 孔祥波 py.konger在gmail.com
星期二 九月 12 21:27:59 HKT 2006

for i in range(0,len(str):
      print hex(int(str[i]))


2006/9/12, zhangpf <zhangpf在ichaier.com>:
>
> ÓÐÒ»¸ö¶þ½øÖƵÄbitÎļþ£¬Ïë°ÑËûµÄÄÚÈÝת»¯Îª16½øÖƵÄÎı¾Îļþ£º
>
> fh = open('EBIKE_73H.BIN', 'rb')
> str = fh.read()
> Õâ¸ö¶Áµ½strÀïµÄµ½µ×ÊÇʲô¸ñʽÄØ£¿£¿
>
> ÔÚÍøÉϲéÁ˲éºÃÏñÒªÓÃstruct.unpackת
> ¸ãÁË°ëÌì²»µÃÒªÁì
>
> ÄÇλָµãÒ»ÏÂ
>
> ÎÒÏë°ÑstrÀïµÄ¶«Î÷ÒÔ16½øÖƵÄÐÎʽprint³öÀ´¾Í¿ÉÒÔÁË£¬Ôõô×öÄØ£¿
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20060912/87e9c6df/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:09

笨笨狗 chen.ruijie在gmail.com
星期二 九月 12 22:09:34 HKT 2006

for i in range(0,len(str):
    print hex(int(str[i],2))
似乎这样才可以……


-- 
云电清华同方小民工

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:16

H Ni h.ni.bsd在gmail.com
星期二 九月 12 22:16:38 HKT 2006

for c in str:
    print "%02x" % ord(c)


HN

On 9/12/06, 笨笨狗 <chen.ruijie在gmail.com> wrote:
> for i in range(0,len(str):
>     print hex(int(str[i],2))
> 似乎这样才可以……
>
>
> --
> 云电清华同方小民工
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:21

3751 lwm3751在gmail.com
星期二 九月 12 22:21:54 HKT 2006

有个模块叫binascii

2006/9/12, H Ni <h.ni.bsd at gmail.com>:
> for c in str:
>     print "%02x" % ord(c)
>
>
> HN
>
> On 9/12/06, 笨笨狗 <chen.ruijie at gmail.com> wrote:
> > for i in range(0,len(str):
> >     print hex(int(str[i],2))
> > 似乎这样才可以……
> >
> >
> > --
> > 云电清华同方小民工
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:38

H Ni h.ni.bsd在gmail.com
星期二 九月 12 22:38:43 HKT 2006

hoho, 当时看过这个模块, 可是没注意到hexify

那么应该是:

hexs = binascii(str)


HN

On 9/12/06, 3751 <lwm3751在gmail.com> wrote:
> 有个模块叫binascii
>
> 2006/9/12, H Ni <h.ni.bsd在gmail.com>:
> > for c in str:
> >     print "%02x" % ord(c)
> >
> >
> > HN
> >
> > On 9/12/06, 笨笨狗 <chen.ruijie在gmail.com> wrote:
> > > for i in range(0,len(str):
> > >     print hex(int(str[i],2))
> > > 似乎这样才可以……
> > >
> > >
> > > --
> > > 云电清华同方小民工
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:41

H Ni h.ni.bsd在gmail.com
星期二 九月 12 22:41:37 HKT 2006

对不起, 是hexlify

HN

On 9/12/06, H Ni <h.ni.bsd在gmail.com> wrote:
> hoho, 当时看过这个模块, 可是没注意到hexify
>
> 那么应该是:
>
> hexs = binascii(str)
>
>
> HN
>
> On 9/12/06, 3751 <lwm3751在gmail.com> wrote:
> > 有个模块叫binascii
> >
> > 2006/9/12, H Ni <h.ni.bsd在gmail.com>:
> > > for c in str:
> > >     print "%02x" % ord(c)
> > >
> > >
> > > HN
> > >
> > > On 9/12/06, 笨笨狗 <chen.ruijie在gmail.com> wrote:
> > > > for i in range(0,len(str):
> > > >     print hex(int(str[i],2))
> > > > 似乎这样才可以……
> > > >
> > > >
> > > > --
> > > > 云电清华同方小民工
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 22:43

H Ni h.ni.bsd在gmail.com
星期二 九月 12 22:43:03 HKT 2006

又错了, 今天诸事不宜呀

hexs = binascii.hexlify(str)


HN

On 9/12/06, H Ni <h.ni.bsd在gmail.com> wrote:
> 对不起, 是hexlify
>
> HN
>
> On 9/12/06, H Ni <h.ni.bsd在gmail.com> wrote:
> > hoho, 当时看过这个模块, 可是没注意到hexify
> >
> > 那么应该是:
> >
> > hexs = binascii(str)
> >
> >
> > HN
> >
> > On 9/12/06, 3751 <lwm3751在gmail.com> wrote:
> > > 有个模块叫binascii
> > >
> > > 2006/9/12, H Ni <h.ni.bsd在gmail.com>:
> > > > for c in str:
> > > >     print "%02x" % ord(c)
> > > >
> > > >
> > > > HN
> > > >
> > > > On 9/12/06, 笨笨狗 <chen.ruijie在gmail.com> wrote:
> > > > > for i in range(0,len(str):
> > > > >     print hex(int(str[i],2))
> > > > > 似乎这样才可以……
> > > > >
> > > > >
> > > > > --
> > > > > 云电清华同方小民工
> > > > > _______________________________________________
> > > > > python-chinese
> > > > > Post: send python-chinese在lists.python.cn
> > > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > > _______________________________________________
> > > > python-chinese
> > > > Post: send python-chinese在lists.python.cn
> > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号