Avatar ·

Sequential character shifting in a string

📁 Advanced Python Topics

Strings of different arbitrary lengths, various characters. How to perform a shift of string characters by one character and sequentially iterate through all variants, so that from the string 1a2b3c we get:

1a2b3ca2b3c12b3c1ab3c1a23c1a2bc1a2b3

It is required to include such a script in a pipe in the terminal using Unix ToolBox, Python, Perl.

Avatar ·

To print a file containing UTF-8 encoded text to the console (analogous to type filename in cmd.exe) in Python:

#!/usr/bin/env python3import shutilimport syswith open(filename, encoding='utf-8') as file:    shutil.copyfileobj(file, sys.stdout)

If you want to print Unicode characters that are not representable in the chcp encoding (OEM code page), see

Log in to leave an answer

Blogs