次のコードで BeautifulSoup を使用して、いくつかの html ドキュメントのタイトル タグを変更しようとしています。
>>> doc = BeautifulSoup(open(filename))
>>> root = doc.find('html') # works only with html parser
>>> hafta = root.find(id="hafta")
>>> content = hafta.find('div', {'class':'convHtml'})
>>> content.find('b').string
u'BAKANLARA N\u0130\xc7\u0130N KURBAN KES\u0130L\u0130R?'
>>> doc.title.string = content.find('b').string
>>> content.find('b').string
>>>
奇妙なことに、このステートメントdoc.title.string = content.find('b').string
は 内の文字列をクリアしますcontent.find('b')
。なぜこれが起こるのですか?