python文件的打开,Python文件打开并立即关闭

Tried running this code first through powershell and then through cmd and even simply clicking it. I am typing "start python myfile.py" to run it. In each case, the file blinks on screen and immediately closes.

The only way I can view it is to drag the file directly into cmd, in which case it looks perfect.

I am doing the first exercise from "Learn Python the Hard Way". I'm doing everything to the letter as in the book, with one exception. See below*. I've read and re-read it.

I don't think this matters, but the book tells me to simply write, "python" "notepad" etc. to run those (and other) programs from my terminal. And I figured out I have to write, "start python", "start notepad", etc. for it to actually run.

As per suggestions to this problem on other similar questions here, I have attempted to end my code with 1.) main() 2.) raw_input() and

3.) if __name__ == '__main__':

main()

No success. Here is my file code which I made in Notepad++:

print "Hello World!"

print "Hello again"

print "I like typing this."

print "This is fun."

print 'Yay! Printing.'

print "I'd much rather you 'not'."

print 'I "said" do not touch this.'

So pretty much, the program executes and closes itself. How might I keep it open in python on its own?

It has been hours of trying to figure this out and this seriously seems like it should be so simple. Could someone please, pretty please, pleeeease point me in the right direction?

解决方案input("Press Enter to continue...")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值