A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

I am very new, and am attempting to learn the Python language so please forgive my ignorance.Here is the problem, whenever I run a Python script from the cmd prompt as soon as it runs it (cmd prompt screen) dissappears immediately after running. How do you keep the cmd screen open with whatever the last print command has on screen ?

  • This Question is Closed
  1. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    I think if you right-click on the file and go to its properties you may have an option. There are two better ways to do it. One is to run it from an already-open command prompt; e.g., hit Windows-R to bring up the run dialog, type `cmd' and enter to bring up a command prompt, then type `cd C:\<whatever>' where <whatever> is the folder where your file is, and then run `python myfile.py'. The second way is to make it so that your script itself waits for you to hit enter before it quits. I believe the way to do that in Python is to put a single `raw_input' statement at the end of the file. That will wait for you to hit enter before the script ends, and therefore before the command prompt closes.

  2. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    raw_input() will work fine for that.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks for the help i'll give it a try.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    the raw_input() works Thank you

  5. shadowfiend
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Awesome! :)

  6. carlsmith
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    @rcvegas40 I've been learning Python for a couple of years, I'm not brilliant at it, but I've got it down. If you have any problems at all, just post a question in the Computer Science Group or the MIT 6.0 Group and I'd be happy to help. There's a couple of other guys on here too. They'd be happy to help if you need anything. Welcome to the site by the way :)

  7. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.