[英]How can I format clipboard data in Javascript to create soft line breaks when pasted into MS Word?
[英]How can I keep line breaks when sending data from one django application to another
用戶在文本區域(HTML)中編寫代碼,我將表單發布為:
<form id="codeid" method="post" enctype="application/x-www-form-urlencoded" name="code" action="192.168.56.2:8000/api/comp/">
<input id="textarea_1" name="content" cols="80" rows="15" type="text" onkeypress="return runScript(event)"></input>
<input id="thebutton" type="button" value="Submit" onclick="document.forms.codeid.submit();" />
</form>
用"application/x-www-form-urlencoded"
編碼數據似乎不足以編碼換行符,
這是我將數據發送到另一個應用程序的方式:
def comp(request):
data = request.POST['content']
url = urllib2.urlopen('http://192.168.56.2:8000/api/comp/?' + data)
redirect('http://192.168.56.2:8000/api/comp/?' + data)
tml = url.read()
return HttpResponse(encoded_data)
因此,例如,當用戶鍵入python代碼時;
def current_datetime(request):
current_date=datetime.datetime.now()
return render_to_response('index.html', locals())
這是收到的:
def+current_datetime%28request%29%3A++++current_date%3Ddatetime.datetime.now%28%29++++return+render_to_response%28%27index.html%27%2C+locals%28%29%29
沒有用於換行符的編碼。 我試圖從鍵盤上捕獲<enter>
事件,並將\\n
添加到文本區域的值,但這沒有用。
謝謝。
在將數據附加到URL之前,您可能需要urllib.urlquote()
:
>>> import urllib
>>> urllib.quote('\n')
'%0A'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.