Skip to content

An small error for the function "image to txt" and the work function for "image to image" change in order to work on python 3.8 or later#52

Open
QianziTech wants to merge 9 commits intovietnh1009:masterfrom
QianziTech:master
Open

An small error for the function "image to txt" and the work function for "image to image" change in order to work on python 3.8 or later#52
QianziTech wants to merge 9 commits intovietnh1009:masterfrom
QianziTech:master

Conversation

@QianziTech
Copy link
Copy Markdown

As the default setting with the 'complex' mode,the source didn't have the 'r' in start of the 'CHAR_LIST',which could course error because of the"\".
The following screenshoot show the error for your origin code:
屏幕截图 2024-11-20 164346

… the 'r' in start of the 'CHAR_LIST',which could course error because of the"\".
@QianziTech
Copy link
Copy Markdown
Author

Sorry.I use python 3.12 when i found the error.
After I create this request,I use Python 3.8 and your original code and it could work again.However,This small change could help the code work in python 3.12.

@QianziTech QianziTech changed the title An error fot image to txt An small error for the function "image to txt" in python 3.12 Nov 20, 2024
@H-Sofie H-Sofie mentioned this pull request Nov 21, 2024
Comment thread img2txt.py Outdated
CHAR_LIST = '@%#*+=-:. '
else:
CHAR_LIST = "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. "
CHAR_LIST = r"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. "
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not correct, considering

>>> len(r"\"")
2
>>> r"\""[0]
'\\'
>>> r"\""[1]
'"'

So there will be two \ in CHAR_LIST (previously there is zero).

My suggestion is

Suggested change
CHAR_LIST = r"$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. "
CHAR_LIST = r"""$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. """

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh,thanks for your advice

@QianziTech QianziTech changed the title An small error for the function "image to txt" in python 3.12 An small error for the function "image to txt" and the work function for "image to image" change in order to work on python 3.8 or later Nov 23, 2024
@QianziTech
Copy link
Copy Markdown
Author

By the way,I also change the work function on "image to image",so it could work correctly on python 3.8 or later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants