test.py 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import base64
  2. import io
  3. import numpy as np
  4. import cv2
  5. from PIL import Image
  6. from utils import base64_decode
  7. # with open(r"C:\Users\Administrator\Desktop\base64_2.txt", "r") as f:
  8. # _str = f.read()
  9. #
  10. # _str, _str_old = base64_decode(_str, is_test=True)
  11. # print(len(_str_old)%4)
  12. #
  13. # with open(r"C:\Users\Administrator\Desktop\base64_wrong.txt", "w") as f:
  14. # f.write(_str_old)
  15. #
  16. # image_np = cv2.imdecode(np.frombuffer(_str, np.uint8), cv2.IMREAD_COLOR)
  17. # cv2.imshow("i", image_np)
  18. # cv2.waitKey(0)
  19. # with open(r"C:\Users\Administrator\Desktop\2.png", "rb") as f:
  20. # _str = f.read()
  21. # _str = base64.b64encode(_str)
  22. # with open(r"C:\Users\Administrator\Desktop\base64_right.txt", "wb") as f:
  23. # f.write(_str)
  24. #
  25. # _str = base64.b64decode(_str)
  26. # image_np = cv2.imdecode(np.frombuffer(_str, np.uint8), cv2.IMREAD_COLOR)
  27. # cv2.imshow("i", image_np)
  28. # cv2.waitKey(0)
  29. # with open(r"C:\Users\Administrator\Desktop\2.jpg", "wb") as f:
  30. # f.write(_str)
  31. _l = [None, 1, None]
  32. print(_l.count(None))