Created
October 9, 2025 16:20
-
-
Save Mariatta/b53a30c8d41a43add0e491ffc66f897b to your computer and use it in GitHub Desktop.
Convert a string into a uuid-format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example script for converting from 'e032ef8ab56d4ee18b388973a5cfc766' into 'e032ef8a-b56d-4ee1-8b38-8973a5cfc766' | |
| import uuid | |
| def convert_to_uuid(input): | |
| """Convert the input into uuid format.""" | |
| return str(uuid.UUID(input)) | |
| input_str("e032ef8ab56d4ee18b388973a5cfc766") | |
| output = convert_to_uuid(input_str) | |
| print(output) | |
| # example call | |
| # >>> convert_to_uuid("e032ef8ab56d4ee18b388973a5cfc766") | |
| # 'e032ef8a-b56d-4ee1-8b38-8973a5cfc766' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment