对我来说是pyton吗? [英] Is pyton for me?

查看:88
本文介绍了对我来说是pyton吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要编写简单的脚本来执行命令行功能。到目前为止,我已经使用了C-Shell脚本,但我正在寻找更好的选择。我一直在阅读如何?简单?它是用python编程的。


不幸的是在读完diveintopython之后和python教程,我不知道如何做我需要做的事。


这是我希望能够做的事情的一个例子。我可以用python做到这一点吗?如何让python执行命令行函数?


I need to write simple scripts for executing command line functions. Up till now I''ve used C-Shell scripts for this, but I''m looking for a better alternative. And I keep reading about how ?easy? it is to program with python.

Unfortunately after reading "diveintopython" and the python tutorial, I''m not sure how to do what I need to do.

Here is an example of the type of thing I would like to be able to do. Can I do this with python? How do I get python to execute command line functions?

从命令提示符(不是从python解释器?运行linux)我会输入:
From the command prompt (not from the python interpreter ? running linux for example) I would type:




gensky 3 21 12> sky.rad


这会调用非python程序吗?gensky?这将在3月21日中午12点创建一个天空的计算机模型,并将此信息放入名为sky.rad的文件中。


如果我创建一个CSH脚本,如下所示,我可以通过以下方式构建循环来自动执行任务:


#!/ bin / csh -fv


#创建简单脚本多个天空文件。


foreach小时(10 12 14)

gensky 3 21 $ hour> sky $ hour.rad

end


如果我尝试从python解释器或python.py文件中执行gensky命令,我会收到错误消息:


NameError:name?gensky?没有定义


所以即使我得到python语法正确,我也无法执行这些命令。


如果有人有关于如何让python脚本执行此类事情的任何建议,我应该看到的内容,或者除了python之外还有其他我可能会考虑的内容,请告诉我。


感谢您的帮助。


马克


_______________________________________________

加入Excite! - http://www.excite.com

最多Web上的个性化门户网站!



gensky 3 21 12 > sky.rad

This would call the non-python program ?gensky? which creates a computer model of a sky on march 21st at 12:00 PM and puts this information into a file called sky.rad.

If I create a CSH script like the one below, I can automate tasks by building loops along the lines of:

#!/bin/csh -fv

# simple script to create multiple sky files.

foreach hour (10 12 14)
gensky 3 21 $hour > sky$hour.rad
end

If I try and do a gensky command from the python interpreter or within a python.py file, I get an error message:

NameError: name ?gensky? is not defined

So even if I get the python syntax correct, I can?t get these commands to execute.

If anyone has any suggestions on how to get python scripts to execute this sort of thing, what I should be looking at, or if there is something else I might consider besides python, please let me know.

Thanks for your help.

Mark

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

推荐答案

hour> sky
hour > sky


hour.rad

end


如果我尝试从python解释器或内部执行gensky命令一个python.py文件,我收到一条错误消息:


NameError:name?gensky?没有定义


所以即使我得到python语法正确,我也无法执行这些命令。


如果有人有关于如何让python脚本执行此类事情的任何建议,我应该看到的内容,或者除了python之外还有其他我可能会考虑的内容,请告诉我。


感谢您的帮助。


马克


_______________________________________________

加入Excite! - http://www.excite.com

最多Web上的个性化门户网站!
hour.rad
end

If I try and do a gensky command from the python interpreter or within a python.py file, I get an error message:

NameError: name ?gensky? is not defined

So even if I get the python syntax correct, I can?t get these commands to execute.

If anyone has any suggestions on how to get python scripts to execute this sort of thing, what I should be looking at, or if there is something else I might consider besides python, please let me know.

Thanks for your help.

Mark

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!


Mark de + la + Fuente写道:
Mark de+la+Fuente wrote:
我需要编写简单的脚本来执行命令行功能。直到现在我已经使用了C-Shell脚本,但我正在寻找更好的替代方案。我一直在阅读简单的方法。它是用
python编程的。

不幸的是,在读完diveintopython之后和python教程,我不确定如何做我需要做的事。

以下是我希望能够做的事情的一个例子。
我可以用python做到这一点吗?如何让python执行命令行
函数?
I need to write simple scripts for executing command line functions. Up till
now I''ve used C-Shell scripts for this, but I''m looking for a better
alternative. And I keep reading about how "easy" it is to program with
python.

Unfortunately after reading "diveintopython" and the python tutorial, I''m not
sure how to do what I need to do.

Here is an example of the type of thing I would like to be able to do.
Can I do this with python? How do I get python to execute command line
functions?



import os

os.system(''gensky 3 21 12> sky.rad'')



import os
os.system(''gensky 3 21 12 > sky.rad'')


这篇关于对我来说是pyton吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆