需要python的帮助 [英] need help with python

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

问题描述

是的,所以我非常喜欢这个整个python的东西...它很漂亮

很酷,但我刚刚开始今天我已经遇到麻烦了。我b $ b开始使用我在某处找到的教程,我按照

说明进行操作,但无法获得正确的结果。下面是代码

东西......


温度=输入(垃圾邮件的温度是多少?)

如果温度> 50:

打印沙拉正确煮熟。

否则:

打印煮沙拉还有更多。


我想要这样做但是当我告诉它什么是垃圾邮件

温度时,它就关掉......好吧它首先在

工作,直到我意识到我没有完全正确地按照说明

并且我应该在
记事本然后保存并打开python ...所以,当它问我

垃圾邮件的温度是什么,然后我键入一个数字然后它就关闭了

本身...我真的不确定出了什么问题......如果

有人会像导师那样......那就很好......

解决方案

2007年5月11日18:47:27 -070 0, ad*******@hotmail.com

< ad *******@hotmail.com写的:


ya所以我对这个整个python的东西非常陌生......它漂亮

很酷,但我刚刚开始,我已经遇到了麻烦。我b $ b开始使用我在某处找到的教程,我按照

说明进行操作,但无法获得正确的结果。下面是代码

东西......


温度=输入(垃圾邮件的温度是多少?)

如果温度> 50:

打印沙拉正确煮熟。

否则:

打印煮沙拉还有更多。


我想要这样做但是当我告诉它什么是垃圾邮件

温度时,它就关掉......好吧它首先在

工作,直到我意识到我没有完全正确地按照说明

并且我应该在
记事本然后保存并打开python ...所以,当它问我

垃圾邮件的温度是什么,然后我键入一个数字然后它就关闭了

本身...我真的不确定出了什么问题......如果

有人会像导师或其他什么东西那么真的很好......



我在这里做了几个假设(c如果我错了,请告诉我):


1.你正在使用windows

2.你双击.py文件


这样做是打开一个新的终端窗口并开始执行

程序。程序将执行完毕,然后

窗口将自动关闭,而无需等待你告诉它

(可爱的不是吗?)。为了解决这个问题,你有两个选择:


1.从命令行运行脚本

2.将它放在.py的末尾file:input(''按ENTER继续'')


Ian


5月11日晚上9:11, 伊恩克拉克 < turb ... @ gmail.comwrote:


2007年5月11日18:47:27 -0700,adamur ... @ hotmail.com


< adamur ... @ hotmail.comwrote:


ya所以我几乎是这个整个python的新东西..它很漂亮

很酷,但我刚刚开始,我已经遇到麻烦了。我b $ b开始使用我在某处找到的教程,我按照

说明进行操作,但无法获得正确的结果。下面是代码

stuff ...


temperature = input(垃圾邮件的温度是多少? ;)

如果温度> 50:

打印沙拉正确煮熟。

否则:

print再煮一些沙拉。


ya我试图这样做但当我告诉它什么是垃圾邮件

温度时,它只是关闭......好吧它首先在

工作,直到我意识到我没有完全正确地按照说明

并且我应该输入该代码一个

记事本然后保存并打开python ...所以,当它问我

什么温度的垃圾邮件和我键入一个数字然后它只是关闭

本身......我真的不确定出了什么问题......如果

有人会像导师那样......那么真的很好......



我在这里做了几个假设(纠正我,如果我错了):


1.你正在使用windows

2.你双击.py文件


这样做是为了打开一个新的终端窗口并开始执行

该计划。程序将执行完毕,然后

窗口将自动关闭,而无需等待你告诉它

(可爱的不是吗?)。为了解决这个问题,你有两个选择:


1.从命令行运行脚本

2.将它放在.py的末尾file:input(''按ENTER键继续'')


Ian



ok你用过一堆花哨的词在那...我不知道什么是.py

文件是...我正在使用Windows ...我不知道什么是终端窗口

但我要点击它就是当你点击python的东西...你我有点想知道你说的是什么但事情是我想让它给我

反馈给我的问题它为什么会那样...嗯非常

令人困惑...我不知道如何从命令运行脚本

line ...哦是的输入事情有效。谢谢你...哦,

命令行必须是lil黑盒...如果我把它放在那里它那么

会给我一堆语法这个和错误那种东西...

这就是为什么我把它放在记事本中加上教程说...


< blockquote> 5月11日,8:47 pm,adamur ... @ hotmail.com写道:


ya所以我几乎是这个整个python的新手。 ..它很漂亮

很酷,但我刚刚开始,我已经遇到麻烦了。我b $ b开始使用我在某处找到的教程,我按照

说明进行操作,但无法获得正确的结果。下面是代码

东西......


温度=输入(垃圾邮件的温度是多少?)

如果温度> 50:

打印沙拉正确煮熟。

否则:

打印煮沙拉还有更多。


我想要这样做但是当我告诉它什么是垃圾邮件

温度时,它就关掉......好吧它首先在

工作,直到我意识到我没有完全正确地按照说明

并且我应该在
记事本然后保存并打开python ...所以,当它问我

垃圾邮件的温度是什么,然后我键入一个数字然后它就关闭了

本身......我真的不确定出了什么问题......如果

有人会像导师或其他什么东西那么真的很好......



嗯,这个清单有不同程度的指导和新手容忍度,

对于那些在发布这里是我的作业问题之类的事情之前已经做了一些努力开始的人来说更加宽容,请发送我用

工作代码,所以我可以把它交给我。


我只是在Python提示下以交互方式运行代码,它运行

就好了。请参阅?


>> temperature = input(" the temperature of the temperature of the temperature垃圾邮件?")



垃圾邮件的温度是多少?55


>> if temperature> 50:



....打印正确煮熟的沙拉。

....其他:

....打印沙拉是正确煮熟。

....

沙拉正确煮熟。


我认为你遇到的问题就是这样,当你通过在文件浏览器中双击xyz.py文件来运行你的程序

时,操作系统

(Windows,我假设?)打开一个单独的控制台窗口,并运行

程序,然后在编程结束时ram,关闭窗口。我认为你的代码运行得很好,我认为你的沙拉是

无论如何消息打印出来,但之后,你的程序结束了,

所以关闭窗口才能看到你的沙拉结果如何。


一个简单的解决方法你可以做的是添加到你的程序结束

这个声明:


输入(<<按返回结束程序>")


这将导致进程停止并等待您按

RETURN键,让您有时间停下来欣赏您的沙拉结果
在关闭窗口之前



最后一个注意事项:许多人发帖写着像我说话一样写。样式。这个

在讲述你的故事时是可以的(好吧,它首先没有工作在

首先......),而且所有这些都是 - 小写是可以通过的,但请

删除ya。他们是一个口头的抽搐,可能是好的,但

根本没有翻译成书面帖子。至少你不会说

" like每隔一个字,谢谢你! :)


通过阅读

comp.lang.python档案,您可以了解其他写作风格。我还建议您在刚入门中找到更多的人。阶段发布到python-

家庭邮件列表(转到 http://mail.python.org/mailman/listinfo/tutor)

您可以浏览那里的帖子,了解许多介绍性主题。


祝您好运,欢迎使用Python!


- Paul


ya so im pretty much a newb to this whole python thing... its pretty
cool but i just started today and im already having trouble. i
started to use a tutorial that i found somewhere and i followed the
instructions and couldnt get the correct results. heres the code
stuff...

temperature=input("what is the temperature of the spam?")
if temperature>50:
print "the salad is properly cooked."
else:
print "cook the salad some more."

ya i was trying to do that but when i told it what the spams
temperature was, it just turned off... well it wasnt working at all at
first until i realized that i hadnt been following the instructions
completely correctly and that i was supposed to type that code up in a
notepad then save and open with python... so ya thats when it asked me
what temperature the spam was and i typed a number then it just closed
itself... im not really sure what went wrong... itd be real nice if
someone would be like a mentor or something...

解决方案

On 11 May 2007 18:47:27 -0700, ad*******@hotmail.com
<ad*******@hotmail.comwrote:

ya so im pretty much a newb to this whole python thing... its pretty
cool but i just started today and im already having trouble. i
started to use a tutorial that i found somewhere and i followed the
instructions and couldnt get the correct results. heres the code
stuff...

temperature=input("what is the temperature of the spam?")
if temperature>50:
print "the salad is properly cooked."
else:
print "cook the salad some more."

ya i was trying to do that but when i told it what the spams
temperature was, it just turned off... well it wasnt working at all at
first until i realized that i hadnt been following the instructions
completely correctly and that i was supposed to type that code up in a
notepad then save and open with python... so ya thats when it asked me
what temperature the spam was and i typed a number then it just closed
itself... im not really sure what went wrong... itd be real nice if
someone would be like a mentor or something...

I''m making a couple of assumptions here (correct me if I''m wrong):

1. You''re using windows
2. You double clicked on the .py file

What this does is open up a new terminal window and start execution of
the program. The program will execute to completion and then the
window will close automatically without waiting for you to tell it to
(lovely isn''t it?). To get around this you have a couple options:

1. Run the script from the command line
2. Put this at the end of the .py file: input(''Press ENTER to continue'')

Ian


On May 11, 9:11 pm, "Ian Clark" <turb...@gmail.comwrote:

On 11 May 2007 18:47:27 -0700, adamur...@hotmail.com

<adamur...@hotmail.comwrote:

ya so im pretty much a newb to this whole python thing... its pretty
cool but i just started today and im already having trouble. i
started to use a tutorial that i found somewhere and i followed the
instructions and couldnt get the correct results. heres the code
stuff...

temperature=input("what is the temperature of the spam?")
if temperature>50:
print "the salad is properly cooked."
else:
print "cook the salad some more."

ya i was trying to do that but when i told it what the spams
temperature was, it just turned off... well it wasnt working at all at
first until i realized that i hadnt been following the instructions
completely correctly and that i was supposed to type that code up in a
notepad then save and open with python... so ya thats when it asked me
what temperature the spam was and i typed a number then it just closed
itself... im not really sure what went wrong... itd be real nice if
someone would be like a mentor or something...


I''m making a couple of assumptions here (correct me if I''m wrong):

1. You''re using windows
2. You double clicked on the .py file

What this does is open up a new terminal window and start execution of
the program. The program will execute to completion and then the
window will close automatically without waiting for you to tell it to
(lovely isn''t it?). To get around this you have a couple options:

1. Run the script from the command line
2. Put this at the end of the .py file: input(''Press ENTER to continue'')

Ian

ok u used a bunch of fancy words in there... im not sure what a .py
file is... i am using windows... i dont know what a terminal window is
but im gonna asume that it is when you click the python thing... ya i
kinda understand what ur sayin but the thing is i wanted it to give
feedback to my question and why would it do that... hmmm very
confusing... im not sure how to run the script from the command
line... oh yeah the enter thing worked. thanks for that... oh the
command line must be the lil black box... if i put it there then it
will give me a bunch of syntax this and error that kinda stuff...
thats why im putin it in the notepad and plus the tutorial said to...


On May 11, 8:47 pm, adamur...@hotmail.com wrote:

ya so im pretty much a newb to this whole python thing... its pretty
cool but i just started today and im already having trouble. i
started to use a tutorial that i found somewhere and i followed the
instructions and couldnt get the correct results. heres the code
stuff...

temperature=input("what is the temperature of the spam?")
if temperature>50:
print "the salad is properly cooked."
else:
print "cook the salad some more."

ya i was trying to do that but when i told it what the spams
temperature was, it just turned off... well it wasnt working at all at
first until i realized that i hadnt been following the instructions
completely correctly and that i was supposed to type that code up in a
notepad then save and open with python... so ya thats when it asked me
what temperature the spam was and i typed a number then it just closed
itself... im not really sure what went wrong... itd be real nice if
someone would be like a mentor or something...

Well, this list has a varying level of mentoring and newbie-tolerance,
with more latitude for people who have made some effort to start with
before posting things like "here''s my homework problem, please send me
the working code so I can hand it in."

I just ran your code interactively at the Python prompt, and it runs
just fine. See?

>>temperature=input("what is the temperature of the spam?")

what is the temperature of the spam?55

>>if temperature>50:

.... print "the salad is properly cooked."
.... else:
.... print "the salad is properly cooked."
....
the salad is properly cooked.

I think the problem you are having is that, when you run your program
by double-clicking on the xyz.py file in a file browser, the OS
(Windows, I assume?) opens a separate console window, and runs the
program, and then at the end of the program, CLOSES the window. I
think your code is running just fine, I think your "the salad is
whatever" messages get printed out, but afterward, your program ends,
so the window closes before you can see how your salad turned out.

A simple workaround you can do is to add to the end of your program
this statement:

input("<press return to end program>")

This will cause the process to stop and wait for you to press the
RETURN key, giving you time to stop and admire your salad results
before closing the window.

One final note: many people post in a "write like I talk" style. This
is okay while telling your story ("well it wasn''t working at all at
first..."), and the ee cummings all-lower-case is passable, but please
drop the "ya"s. They are a verbal tic that may be okay in person, but
do not translate at all to written posts. At least you don''t say
"like" every other word, and I thank you for that! :)

You can get a sense of other writing styles by reading through the
comp.lang.python archives. I would also recommend that you might find
more folks in the "just getting started" phase posting to the python-
tutor mailing list (go to http://mail.python.org/mailman/listinfo/tutor),
and you can skim through posts there for many introductory topics.

Good luck to you, and welcome to Python!

-- Paul


这篇关于需要python的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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