우리는 미래에 자주 사용할 중요한 웹사이트를 기억하기 위해 북마크를 사용합니다. 다음은 웹 사이트의 URL을 첫 번째 입력으로 사용하고 웹 사이트를 열려는 시간을 두 번째 입력으로 사용하는 간단한 Python 코드입니다. 시간이 주어진 시간 값에 도달하면 웹 브라우저에서 요청한 URL이 자동으로 열립니다. 이 코드에서는 Time과 Webbrowser라는 두 개의 Python 모듈을 가져옵니다.
비교 가능한 목록Python3
# Import the time module it provides various time-related # functions. import time # Import the webbrowser module it is used to # display various HTML documents to the user. import webbrowser # First Input: It is the time of the form # 'Hours:Minutes:Seconds' that you'll # use to set the alarm. Set_Alarm = input('Set the website alarm as H:M:S:') # Second Input: It is the URL that you want # to open on the given time. url = input('Enter the website you want to open:') # This is the actual time that we will use to print. Actual_Time = time.strftime('%I:%M:%S') # This is the while loop that'll print the time # until it's value will be equal to the alarm time while (Actual_Time != Set_Alarm): print ('The time is ' + Actual_Time) Actual_Time = time.strftime('%I:%M:%S') time.sleep(1) # This if statement plays the role when its the # alarm time and executes the code within it. if (Actual_Time == Set_Alarm): print ('You should see your webpage now :-)') # We are calling the open() # function from the web browser module. webbrowser.open(url)