Use the flag config="--psm 6"
and it should work. This specifies that you have a single uniform block of text. 7 also work which is for a single line of uniform text.
print(pytesseract.image_to_string('test.png', config="--psm 6"))
# prints "06-04-2021 11:27:17\n\x0c"
See this other post for another example https://stackoverflow.com/a/66179528/15271127
EDIT: Also see this website if you want more options https://muthu.co/all-tesseract-ocr-options/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.