python - Context Rendering in Django -


i new in django.so while practising django template in shell saw 2 different output of "render()" .so here goes.

from django.template import template,context t = template("my name {{name}}.") c = context("name":"sraban") t.render(c) 

so while hit enter in shell shows

u'my name sraban' 

but while wrote

from django.template import template,context t = template("my name {{name}}.") c = context("name":"sraban") print t.render(c) 

it's output

my name sraban 

so want know "u" in first output , why 2 output varies??? use django1.6 in python 2.7.3 .

the u means string unicode string. called string prefix. reason appears in first example default way represent value in interactive shell use value function repr returns when called value argument. second example missing prefix because print doesn't use repr-representation strings, actual value.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -