How to Convert String to Byte

WhitneyL2023 5 Reputation points
2023-08-23T02:27:19.77+00:00

I'm downloading a file in a pipeline and need to convert a string to a byte before decrypting it. The error is "At most 45 bytes at once"

test_string = "container/folder1/folder2/file.txt"

res = bytes(test_string, 'ascii')

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 33,071 Reputation points Volunteer Moderator
    2023-08-23T14:21:59.4533333+00:00

    The code snippet you have provided is correct for converting a string to bytes in Python using ASCII encoding.

    However, the error message "At most 45 bytes at once" might be related to something else in your code or the specific function you're calling that requires the byte conversion.

    Try the following :

    test_string = "container/folder1/folder2/file.txt"
    res = bytes(test_string, 'utf-8')
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.