T
T
This_is_MonoliT2022-04-03 23:51:42
Computer networks
This_is_MonoliT, 2022-04-03 23:51:42

How to know if there is an internet connection in Python?

How do I know if there is an internet connection on a PC (Windows)

Using Python

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gedeys, 2022-04-04
@This_is_MonoliT

import requests
if requests.get('http://ya.ru').ok:
    print('Есть контакт!')

W
Wispik, 2022-04-03
@Wispik

Make a request to some site (ya.ru for example), the answer will be returned, which means there is Internet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question