简体   繁体   中英

Parsing '\n' to '\n ctrl-l' with Python

I have a program that can access Python from inside within it's initial file, that looks like

#initial file
source py_commands.py
py_cmd

I want to grep from inside that program \\n and parse it to \\n ctrl-l . Ctrl-l is just a combined key stroke like in bash, screen or other TUI and invokes a command in this program, which I otherwise always have manually to type and should only be invoked after a \\n .

I tried this without success:

x = raw_input()
print(x + '\u000C')

I'm not well versed in Python and only need this one piece. Any help is appreciated.

raw_input() strips the trailing newline. If you want the string to end with \\n \\f (Ctrl-L is Form Feed ), you have to add both.

x = raw_input()
print(x+'\n\f')

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM