0

I'm working with Windows :

import os
import http.client as h

co = h.HTTPSConnection("www.google.com")
co.request("GET","/")
res = co.getresponse()
print(res.status,res.reason)
os.system("pause")

When I open the command line, all work perfectly : "200 OK"

But when I copy this in a file and save it, I have an error and the programm stop. I found a "solution", when I run my app, the folder "__pycache__" containing "http.cpython-34" is created. And I have to open the "http.cpython-34" file to see "200 OK" Is there another way to run correctly my programm without opening the "http.cpython-34" file ?

EDIT : I found the solution. My file was called http.py. But when I rename it, it work perfectly :)

1 Answers1

-1

I don't think os.system("pause") is what you want to use here. That will try to launch a subprocess with the command pause, which will not actually pause the running Python program. Generally if you want to pause and wait for a keypress or something you can use raw_input() to pause and wait for user input in Python 2.7 or input() in Python 3.

Nat Dempkowski
  • 2,331
  • 1
  • 19
  • 36