测试.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : 测试.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/8/28
  6. import re
  7. from urllib.parse import quote,unquote
  8. txt = 'var player_aaaa={"flag":"play","encrypt":3,"trysee":0,"points":0,"link":"\/vodplay\/44640-1-1.html","link_next":"","link_pre":"","url":"Zd2fZg56c6y10828ZDRiNzZjNzk1Y2E3OWQzNmQzYWEyM2IwODM0ZjM3MgO0O0OO0O0O","url_next":"d","from":"vip","server":"no","note":"","id":"44640","sid":1,"nid":1}'
  9. ret = re.search('var player_(.*?)=(.*?)<',txt,re.M|re.I)
  10. print(ret)
  11. def encodeStr(input, encoding='GBK'):
  12. """
  13. 指定字符串编码
  14. :param input:
  15. :param encoding:
  16. :return:
  17. """
  18. return quote(input.encode(encoding, 'ignore'))
  19. def lazyParse(input,jsp,getParse,saveParse,headers,encoding):
  20. pass
  21. str1 = '星'
  22. key = str1.encode('gb2312','ignore')
  23. print(quote(key))
  24. print(quote(str1))
  25. # print(str1.decode('utf-8',))
  26. # str_gbk = str1.encode("gbk",ignore=True).strip()
  27. # print("转码结果:"+repr(str_gbk))
  28. # print( unquote('%D0%C7','GBK'))
  29. print(encodeStr('星','utf-8'))
  30. print(encodeStr('斗罗大陆','gbk')) # %B6%B7%C2%DE%B4%F3%C2%BD