Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print confusion

I am new to python when i try to print "\20%" that is

>>>"\20%"

why is the shell printing '\x10%' that is, it is showing

'\x10%'

the same is happening with join also when is do

>>>l = ['test','case']
>>>"\20%".join(l)

it shows

'test\x10%case'

I am using python 2.7.3

like image 459
Pradyumna Avatar asked Jan 15 '13 10:01

Pradyumna


People also ask

What is the purpose of a confusion matrix?

A confusion matrix is a table that is used to define the performance of a classification algorithm. A confusion matrix visualizes and summarizes the performance of a classification algorithm.

What is confusion matrix with example?

Confusion Matrix is a useful machine learning method which allows you to measure Recall, Precision, Accuracy, and AUC-ROC curve. Below given is an example to know the terms True Positive, True Negative, False Negative, and True Negative. True Positive: You projected positive and its turn out to be true.


2 Answers

'\20' is an octal literal, and the same as chr(2 * 8 + 0) == chr(16).

What the Python shell displays by default is not the output of print, but the representation of the given value, which is the hexadecimal '\x10'.

If you want the string \20%, you have to either escape the backaslash ('\\20%') or use a raw string literal (r'\20%'). Both will be displayed as

>>> r'\20%'
'\\20%'
like image 64
phihag Avatar answered Sep 26 '22 14:09

phihag


\20 is an escape sequence that refers to the DLE ASCII character whose decimal value is 16 (20 in octal, 10 in hexadecimal). Such a character is printed as the \x10 hex escape by the repr function of strings.

To specify a literal \20, either double the backslash ("\\20") or use a raw string (r"\20").

like image 44
user4815162342 Avatar answered Sep 26 '22 14:09

user4815162342