How to convert string with special control characters, like \'x1b', into a standard string?
<p>When I use python socket program, we give an option like:</p>

<pre class="lang-none prettyprint-override"><code>1) Input A to show your name
2) Input B to show your age
3) Input other to set your name

&gt;&gt;
</code></pre>

<p>When client types 'Too' + delete button + 'm', server receives 'Too\x1bm'.</p>

<p>How do I convert 'Too\x1bm' to 'Tom' in Python?</p>

<p>There may also be other control characters like 'move cursor' and 'tab'.</p>

<p>If you know all the 'wrong characters' you can use .replace to remove unwanted parts.</p>

<pre><code>'Too\x1bm'.replace(a[a.index('\x1b')-1:a.index('\x1b')+1],'')
returns &gt;&gt;&gt; Tom
</code></pre>

python sockets