1. 08 7月, 2023 30 次提交
  2. 07 7月, 2023 1 次提交
    • N
      Fix UnicodeEncodeError when writing to file CLIP Interrogator Batch Mode · c258dd34
      Neil Mahseth 提交于
      The code snippet print(interrogation_function(img), file=open(os.path.join(ii_output_dir, f"{left}.txt"), 'a')) raises a UnicodeEncodeError with the message "'charmap' codec can't encode character '\u016b' in position 129". This error occurs because the default encoding used by the open() function cannot handle certain Unicode characters.
      
      To fix this issue, the encoding parameter needs to be explicitly specified when opening the file. By using an appropriate encoding, such as 'utf-8', we can ensure that Unicode characters are properly encoded and written to the file.
      
      The updated code should be modified as follows:
      
      python
      Copy code
      print(interrogation_function(img), file=open(os.path.join(ii_output_dir, f"{left}.txt"), 'a', encoding='utf-8'))
      By making this change, the code will no longer raise the UnicodeEncodeError and will correctly handle Unicode characters during the file write operation.
      c258dd34
  3. 06 7月, 2023 2 次提交
  4. 05 7月, 2023 3 次提交
  5. 04 7月, 2023 3 次提交
  6. 03 7月, 2023 1 次提交