File tree Expand file tree Collapse file tree 3 files changed +46
-12
lines changed Expand file tree Collapse file tree 3 files changed +46
-12
lines changed Original file line number Diff line number Diff line change 11# Program to print a data & it's Metadata of online uploaded file using "socket".
22import socket
3- skt_c = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
4- skt_c .connect (("data.pr4e.org" , 80 ))
5- link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r \n \r \n " .encode ()
6- skt_c .send (link )
3+ from colorama import Fore # this module for Color the font
4+
5+ # handling the exceptions
6+ try :
7+ skt_c = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
8+ skt_c .connect (("data.pr4e.org" , 80 ))
9+ link = "GET http://data.pr4e.org/intro-short.txt HTTP/1.0\r \n \r \n " .encode ()
10+ skt_c .send (link )
11+ except (Exception ) as e :
12+ # this code runes on error in any connection
13+ print (Fore .RED , e , Fore .RESET )
714
815while True :
916 data = skt_c .recv (512 )
Original file line number Diff line number Diff line change 11# Importing the required libraries.
22import pyshorteners
3+ from colorama import Fore # this module for font color
34
45# Taking input from the user.
56url = input ("Enter URL: " )
67
7- # Creating an instance of the pyshorteners library.
8- shortener = pyshorteners .Shortener ()
8+ # exception handling
9+ try :
10+ # Creating an instance of the pyshorteners library.
11+ shortener = pyshorteners .Shortener ()
912
10- # Shortening the URL using TinyURL.
11- shortened_URL = shortener .tinyurl .short (url )
13+ # Shortening the URL using TinyURL.
14+ shortened_URL = shortener .tinyurl .short (url )
15+
16+ # Displaying the shortened URL.
17+ print (f"Shortened URL: { shortened_URL } " )
18+ except (Exception ) as e :
19+ # this code runes on any error is generated by user
20+ print (Fore .RED , "Enter Valid URL format" , Fore .RESET )
1221
13- # Displaying the shortened URL.
14- print (f"Shortened URL: { shortened_URL } " )
Original file line number Diff line number Diff line change 1- import xlwt
2- import openpyxl
1+ import xlwt # type: ignore
2+ import openpyxl # type: ignore
33
44# Workbook is created
55xlwt_wb = xlwt .Workbook ()
66
7+ """
8+ we can also use of json object format for this file or code,
9+ for the index we can use (for loop) and for data use json object.
10+ example of json object:
11+ {
12+ "data":[
13+ "ISBT DEHRADUN".
14+ "SHASTRADHARA",
15+ "CLEMEN TOWN",
16+ "RAJPUR ROAD",
17+ "CLOCK TOWER",
18+ "ISBT DEHRADUN",
19+ "SHASTRADHARA",
20+ "CLEMEN TOWN",
21+ "RAJPUR ROAD",
22+ "CLOCK TOWER"
23+ ]
24+ }
25+ """
26+
727# add_sheet is used to create sheet.
828sheet1 = xlwt_wb .add_sheet ("Sheet 1" )
929
You can’t perform that action at this time.
0 commit comments