Home > Software engineering >  How do I start a python application created in visual studio 2022
How do I start a python application created in visual studio 2022

Time:05-08

I saved my python app on desctop. When I click on it opens up for a second and closes again. It runs normally in visual studio.

Thanks in advance

the code is:

import secrets
import string
import pyperclip as pc

alphabet = string.ascii_letters   string.digits
password = ''.join(secrets.choice(alphabet) for i in range(15))  
pc.copy(password)
print (password)    

CodePudding user response:

Add input on the last line.

import secrets
import string
import pyperclip as pc

alphabet = string.ascii_letters   string.digits
password = ''.join(secrets.choice(alphabet) for i in range(15))  
pc.copy(password)
print (password)  
input('Press Enter to Exit')

CodePudding user response:

Python is a scripting language, not something you make compiled "apps" with. You need to open the terminal/cmd prompt and call the script like so:

python my_python_file.py

Then you'll be able to see the output. FWIW the program was running. You just didn't call it from a terminal, so you couldn't see any output. Visual studio is handling this for you.

  • Related