我一直试图用bibtexparser模块解析一些BibTeX记录,即使使用bibtexparser documentation中的相同示例代码,也无法使其工作。
代码是:
import bibtexparser
bibtex = """@ARTICLE{Cesar2013,
author = {Jean César},
title = {An amazing title},
year = {2013},
month = jan,
volume = {12},
pages = {12--23},
journal = {Nice Journal},
abstract = {This is an abstract. This line should be long enough to test
multilines...},
comments = {A comment},
keywords = {keyword1, keyword2}
}
"""
with open('bibtex.bib', 'w') as bibfile:
bibfile.write(bibtex)
with open('bibtex.bib') as bibtex_file:
bibtex_str = bibtex_file.read()
bib_database = bibtexparser.loads(bibtex_str)
print(bib_database.entries)
错误是:
Traceback (most recent call last):
File "path-to-script...", line 12, in <module>
bib_database = bibtexparser.loads(bibtex_str)
AttributeError: 'module' object has no attribute 'loads'
此外,当我尝试列出bibtexparser的属性时,&#34;加载&#34;和#34;加载&#34;不在那里:
dir(bibtexparser)
['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__version__', 'bparser', 'bwriter', 'customization', 'info', 'latexenc']
感谢您的时间。
答案 0 :(得分:0)
pip版本(并且在新版本之前)未破坏。海报根据安装的版本提到了错误的文档版本。