Python论坛  - 讨论区

标题:[python-chinese] 怎么样在控制台中将一个脚本中的内容直接导进来执行?

2007年07月12日 星期四 14:25

周旋 elvis827在gmail.com
星期四 七月 12 14:25:53 HKT 2007

例如test.py中有
x=1
y=2

在控制台中,我想:

执行test.py
print x+y

结果应该打印出3

请问执行test.py这一步怎么做?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070712/9f514028/attachment.html 

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

2007年07月12日 星期四 14:29

Leo Jay python.leojay在gmail.com
星期四 七月 12 14:29:56 HKT 2007

On 7/12/07, 周旋 <elvis827在gmail.com> wrote:
> 例如test.py中有
> x=1
> y=2
>
> 在控制台中,我想:
>
> 执行test.py
> print x+y
>
> 结果应该打印出3
>
> 请问执行test.py这一步怎么做?
>

from test import *

-- 
Best Regards,
Leo Jay

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

2007年07月12日 星期四 14:45

周旋 elvis827在gmail.com
星期四 七月 12 14:45:05 HKT 2007

我试过了,这样好像不行的

2007/7/12, Leo Jay <python.leojay at gmail.com>:
>
> On 7/12/07, 周旋 <elvis827 at gmail.com> wrote:
> > 例如test.py中有
> > x=1
> > y=2
> >
> > 在控制台中,我想:
> >
> > 执行test.py
> > print x+y
> >
> > 结果应该打印出3
> >
> > 请问执行test.py这一步怎么做?
> >
>
> from test import *
>
> --
> Best Regards,
> Leo Jay
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070712/dddc17e3/attachment-0001.htm 

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

2007年07月12日 星期四 15:13

周旋 elvis827在gmail.com
星期四 七月 12 15:13:50 HKT 2007

execfile可以,谢谢~~~

在07-7-13,zhangbaocai_cug <zhangbaocai_cug at tom.com> 写道:
>
>  execfile()
>
>  ------------------------------
>  zhangbaocai_cug
> 2007-07-12
>  ------------------------------
>  *发件人:* 周旋
> *发送时间:* 2007-07-11 23:45:22
> *收件人:* python-chinese at lists.python.cn
> *抄送:*
> *主题:* Re: [python-chinese][CPyUG:28968] 怎么样在控制台中将一个脚本中的内容直接导进来执行?
>
> 我试过了,这样好像不行的
>
> 2007/7/12, Leo Jay <python.leojay at gmail.com>:
> >
> > On 7/12/07, 周旋 <elvis827 at gmail.com> wrote:
> > > 例如test.py中有
> > > x=1
> > > y=2
> > >
> > > 在控制台中,我想:
> > >
> > > 执行test.py
> > > print x+y
> > >
> > > 结果应该打印出3
> > >
> > > 请问执行test.py这一步怎么做?
> > >
> >
> > from test import *
> >
> > --
> > Best Regards,
> > Leo Jay
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070712/4b51ba60/attachment.html 

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

2007年07月12日 星期四 16:18

赵威 zhaoweikid在163.com
星期四 七月 12 16:18:41 HKT 2007

zhangbaocai_cug£¬ÄúºÃ£¡ 

¡¡¡¡°Ñ dll À©Õ¹Ãû»»³É pyd ÊÔÊÔÄØ£¿

======== 2007-07-13 06:05:46 ÄúÔÚÀ´ÐÅÖÐдµÀ£º ========

¿ÉÊÇÓÃboost::pythonÉú³ÉµÄ*.dllÎļþÈ´ÓÖ²»ÄÜimportÁË(IDLEºÍc++ÀïÃæimport¶¼Ê§°Ü).
PS:ÎÒ¶¼ÊÇÓÃrelease°æ±¾µÄ.
ÏÂÃæÊÇDLLµÄ´úÂ룺
#include
#include python.hpp>
using namespace boost::python;



std::string strtmp;
char const* Recognise(const char* url)
{
 strtmp ="´ÓdllÖзµ»ØµÄÊý¾Ý... : ";
 strtmp+=url;
 return strtmp.c_str(); 
}


BOOST_PYTHON_MODULE(TestBoost)
{
 def("Recognise", Recognise);
}






zhangbaocai_cug
2007-07-12

= = = = = = = = = = = = = = = = = = = = = = 
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÕÔÍþ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡zhaoweikid在163.com
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2007-07-12
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070712/59e35e33/attachment.html 

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

2007年07月12日 星期四 16:41

Nicholas Ding nicholasdsj在gmail.com
星期四 七月 12 16:41:52 HKT 2007

python -i test.py
ÏȼÓÔØÎļþÔÙÆô¶¯½»»»»·¾³¡£

On 7/12/07, ÖÜÐý <elvis827在gmail.com> wrote:
>
> execfile¿ÉÒÔ£¬Ð»Ð»¡«¡«¡«
>
> ÔÚ07-7-13£¬zhangbaocai_cug <zhangbaocai_cug在tom.com> дµÀ£º
> >
> >  execfile()
> >
> >  ------------------------------
> >  zhangbaocai_cug
> > 2007-07-12
> >  ------------------------------
> >  *·¢¼þÈË£º* ÖÜÐý
> > *·¢ËÍʱ¼ä£º* 2007-07-11 23:45:22
> > *ÊÕ¼þÈË£º* python-chinese在lists.python.cn
> > *³­ËÍ£º*
> > *Ö÷Ì⣺* Re: [python-chinese][CPyUG:28968] ÔõôÑùÔÚ¿ØÖÆ̨Öн«Ò»¸ö½Å±¾ÖеÄÄÚÈÝÖ±½Óµ¼½øÀ´Ö´ÐУ¿
> >
> > ÎÒÊÔ¹ýÁË£¬ÕâÑùºÃÏñ²»ÐеÄ
> >
> > 2007/7/12, Leo Jay <python.leojay在gmail.com>:
> > >
> > > On 7/12/07, ÖÜÐý <elvis827在gmail.com> wrote:
> > > > ÀýÈçtest.pyÖÐÓÐ
> > > > x=1
> > > > y=2
> > > >
> > > > ÔÚ¿ØÖÆ̨ÖУ¬ÎÒÏ룺
> > > >
> > > > Ö´ÐÐtest.py
> > > > print x+y
> > > >
> > > > ½á¹ûÓ¦¸Ã´òÓ¡³ö3
> > > >
> > > > ÇëÎÊÖ´ÐÐtest.pyÕâÒ»²½Ôõô×ö£¿
> > > >
> > >
> > > from test import *
> > >
> > > --
> > > Best Regards,
> > > Leo Jay
> > > _______________________________________________
> > > 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
>



-- 
Nicholas @ Nirvana Studio
http://www.nirvanastudio.org
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070712/b35a095c/attachment.htm 

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

2007年07月13日 星期五 06:02

zhangbaocai_cug zhangbaocai_cug在tom.com
星期五 七月 13 06:02:27 HKT 2007

execfile()




zhangbaocai_cug
2007-07-12



·¢¼þÈË£º ÖÜÐý
·¢ËÍʱ¼ä£º 2007-07-11 23:45:22
ÊÕ¼þÈË£º python-chinese在lists.python.cn
³­ËÍ£º 
Ö÷Ì⣺ Re: [python-chinese][CPyUG:28968] ÔõôÑùÔÚ¿ØÖÆ̨Öн«Ò»¸ö½Å±¾ÖеÄÄÚÈÝÖ±½Óµ¼½øÀ´Ö´ÐУ¿

ÎÒÊÔ¹ýÁË£¬ÕâÑùºÃÏñ²»ÐеÄ


2007/7/12, Leo Jay <python.leojay在gmail.com>:
On 7/12/07, ÖÜÐý <elvis827在gmail.com> wrote:
> ÀýÈçtest.pyÖÐÓÐ
> x=1
> y=2
>
> ÔÚ¿ØÖÆ̨ÖУ¬ÎÒÏ룺
>
> Ö´ÐÐtest.py
> print x+y
>
> ½á¹ûÓ¦¸Ã´òÓ¡³ö3 
>
> ÇëÎÊÖ´ÐÐtest.pyÕâÒ»²½Ôõô×ö£¿
>

from test import *

--
Best Regards,
Leo Jay
_______________________________________________
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/20070712/28e9b968/attachment.html 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号