In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to solve the problem of garbled code in Python script". In daily operation, I believe that many people have doubts about how to solve the problem of garbled code in Python script. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the problem of "how to solve the problem of garbled code in Python script". Next, please follow the editor to study!
In this case, the question cannot be answered after the script is mounted, and any script about the answer script cannot be used.
Look at this font, I can no longer read the original text. At first, I thought it was an encryption attempt to use an encryption algorithm to crack it, and then tried to decode it with BP and other tools.
After that, an attempt was made to decode it with a coding set, and the result ended in failure. Online search has not been solved.
Finally, I tried to try the complex and simple conversion with the mentality of trying. At first, I didn't believe how simple it was. Did the superstar programmer paddle, and then successfully restore the original topic? Here is the output I restored with Python
# coding = utf-8from zhconv import convertcode_lib = [] scr_lib = [] real_lib = [] code = 'Russian October Revolution opened up a new era of world proletarian socialist revolution' for i in code: decode = ord (I) code_lib.append (decode) for j in scr: decode = ord ( J) scr_lib.append (decode) for k in range (len (code_lib)): real = code_ lib [k]-scr_ Lib [k] real_lib.append (real) print (code_lib) print (scr_lib) print ('- difference -') print (real_lib) print (decode) decode = convert (scr 'zh-hans') print (decode)
Conversion successful
Pip install zhconv
The zhconv library is needed here.
To quickly write a modified JS script: convert Python code to JS code
Pip install jiphy
Need to use jiphy library, as for some problems after JS conversion, some practical problems are actually solved
Finally, the problem of garbled code is complicated and simple conversion, so as long as the original JS script search problem is added to the complex conversion function should be able to solve. The solution, for example, is to convert the entire web page source code from traditional to simplified and then load the JS script.
# coding = utf-8from zhconv import convertimport jiphydef Decode (scr): decode = convert (scr 'zh-hans') return decodedef PyToJs (scr): js = jiphy.to.python (scr) return jsdef JsToPy (scr): py = jiphy.to.javascript (scr) return pyif _ _ name__ =' _ _ main__': # test word = 'traditional character' decode = Decode (word) print (decode) js ='JS Code'py = JsToPy (js) print (py) The study on "how to solve the garbled problem in Python script" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.