NameError: имя «книга» не определено [дубликат]Python

Программы на Python
Ответить
Anonymous
 NameError: имя «книга» не определено [дубликат]

Сообщение Anonymous »

Это мой фрагмент кода:

Код: Выделить всё

#!/usr/bin/python

from xml.etree.ElementTree import ElementTree
from array import *
#import re

count = array('i',[0,0,0])

def find_root_tags(file,str1,i):

tree = ElementTree()
tree.parse(file)
root = tree.getroot()
if root == str1:
count[i] = count[i]+1

for j in tree.getiterator(str1):
count[i] = count[i] + 1

print "%dth file's count %d" % (i,count[i])

str1 = input("enter the word to be searched:")
fo = open("xml.txt","r")

for i in range(count.__len__()):

file = fo.readline()
find_root_tags(file,str1,i)

fo.close()
при запуске моего кода выдается такая ошибка:

Код: Выделить всё

enter the word to be searched:book

Traceback (most recent call last):

File "keywords.py", line 23, in 

str1 = input("enter the word to be searched\n")

File "", line 1, in 

NameError: name 'book' is not defined
почему?

Подробнее здесь: https://stackoverflow.com/questions/112 ... ot-defined
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»