私はappengineでset関数を使用して、ユニークな要素を持つリストを作成しようとしています。私はPythonシェルで正常に動作するPythonコードを書いたとき、私は暗礁に乗り上げるが、AppEngineの中で+appengineではlist()が機能しません。
をDjangoのではないこれは私が(IDLEで、このスクリプトを実行)するつもりです:
import re
value=' [email protected], [email protected],, , [email protected] '
value = value.lower()
value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value)))
if (value[0] == ''):
value.remove('')
print value
所望の出力は、(IDLEでこの出力を得た)です:
['[email protected]', '[email protected]', '[email protected]']
今私はAppEngineの中に私のviews.pyファイルに同等の何かをするとき:
import os
import re
import django
from django.http import HttpResponse
from django.shortcuts import render_to_response # host of other imports also there
def add(request):
value=' [email protected], [email protected],, , [email protected] '
value = value.lower()
value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value)))
if (value[0] == ''):
value.remove('')
return render_to_response('sc-actonform.html', {
'value': value,
})
適切なページ(トレースバックを貼り付け)を行っている間、私はこのエラーを取得する:コメントアウトに
Traceback (most recent call last):
File "G:\Dhushyanth\Google\google_appengine\lib\django\django\core\handlers\base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in add
148. value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value)))
File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in list
208. return respond(request, None, 'sc-base', {'content': responseText})
File "G:\Dhushyanth\development\AppengineProjects\trunk_sanjhachoolha\sandbox\dushyanth\sanjhachoolha\views.py" in respond
115. params['sign_in'] = users.create_login_url(request.path)
AttributeError at /sanjhachoolha/acton/add
'set' object has no attribute 'path'
:
#value = list(set(re.split('^\s*|\s*,+\s*|\s*$', value)))
私は適切なWebページで所望の出力を得る:
[email protected], [email protected],, , [email protected]
を
リスト()が私のトラブルの根本だと確信しています。誰もがなぜこれが起こっているのかを提案する。代替案も提案してください。目的は、リストから重複を削除することです。
ありがとうございます。
申し訳ありませんが、リストは問題です。 – Dhushyanth