在文件中搜索某些单词。。。很奇怪

2024-09-28 20:50:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我真的不知道发生了什么。我在我的搜索栏里查到“嗨”,上面写着找到了两个结果,如果我查到其他词,它只会给我500个错误。有人吗

#! /usr/bin/python

import cgi

data = cgi.FieldStorage()

searchHome = data.getvalue( 'search' )
result = "There was 0 results for search " + searchHome
total = 0
total = int(total)
with open('index.py') as f:
    for line in f:
        finded = line.find(searchHome)
        if finded != -1 and finded != 0:
            total += 1
            total = str(total)
            result = "There was " + total + " result(s) for search term: " + searchHome


print 'Content-type: text/html\n\r\n\r'
print result

谢谢你的帮助,里夫/科尔曼。编辑:刚刚修复了代码:D

更多编辑: 好的,这个错误,我找不到,我浏览了所有的cPanel文件,更多的,查看了帮助,等等。当我查找除“Hi”以外的任何内容时,它只会给我500个错误


Tags: 编辑forsearchdatausr错误lineresult