はAttributeError:「NoneType」オブジェクトが属性を持っていない(パイソン)「を置換」
http://cs1.ucc.ie/~adc2/cgi-bin/lab7/index.html あなたは、ちょうど箱の誰に何を入力することにより、自分のためのエラーをチェックアウトすることができ、すべてである必要はありdoesntの、任意のヘルプは 素晴らしいことだ、私はこの
from cgitb import enable
enable()
from cgi import FieldStorage,escape
print('Content-Type: text/html')
print()
actor=''
genre=''
theyear=''
director=''
mood=''
result=''
form_data= FieldStorage()
if len(form_data) != 0:
try:
actor=escape(form_data.getfirst('actor'))
genre=escape(form_data.getfirst('genre'))
theyear=escape(form_data.getfirst('theyear'))
director=escape(form_data.getfirst('director'))
mood= escape(form_data.getfirst('mood'))
connection = db.connect('####', '###', '####', '###')
cursor = connection.cursor(db.cursors.DictCursor)
cursor.execute("""SELECT title
FROM films
WHERE (actor = '%s')
OR (actor='%s' AND genre='%s')
OR (actor='%s' AND genre='%s' AND theyear='%i')
OR (actor='%s' AND genre='%s' AND theyear='%i' AND director='%s')
OR (actor='%s' AND genre='%s' AND theyear='%i' AND director='%s' AND mood='%s') % (actor, actor,genre, actor,genre,theyear, actor,genre,theyear,director,actor,genre,theyear,director,mood))
""")
result = """<table>
<tr><th>Your movie!</th></tr>
<tr><th></th></tr>"""
for row in cursor.fetchall():
result+= '<tr><td>%s</td></tr>' ,(row['title'])
result+= '</table>'
cursor.close()
connection.close()
except db.Error:
result = '<p>Sorry! We are currently experiencing technical difficulties.</p>'
エラーについてはっきりしないもの: 'replace'を呼び出して、おそらく' str'であると仮定していますが、 'None'です。だから私は入力が正しくAPIを介して実行されないと思う。 –
ありがとう、ありがとう、iveがコードを追加しました –
そのコードで 'str.replace()'の呼び出しが表示されません。あなたの質問に完全なトレースバックを提供してください。 – cdarke