Posts

Showing posts from November, 2021

URL_Symbolic_Replace

 from urllib.parse import unquote class UrlReplace:     def __init__(self):         UrlText = "https://docs.google.com/viewer?url=https%3A%2F%2Fwww.jinhong.org%2Fmoodle%2Fpluginfile.php%2Fgradebook.xlsx"         CleanUrlText = str(unquote(unquote(UrlText)))         print(CleanUrlText.replace("https://docs.google.com/viewer?url=",""))         '''         print("\n")         bibTextPath = "bibTextToReplace" ## put the bibtext at this file under the same path         f = open(bibTextPath, "r", encoding="ISO-8859-1")         finalText = ""         for line in f:             if '={' in line:                 line = line.replace("={", "=\"")             if "}," in line:                 line = line.replace("},", "\",")             finalText = finalText+line         print(finalText.replace("}\n}", "\"\n}"))