The simplest way is to let Python The method that the command line window does not close automatically after the program is run is :
Add the following statement to the end of the program :
input('Press Enter to exit...')
The sample code is as follows :
print('i lov my city')
input('Press Enter to exit...')
The operation results are as follows :