【发布时间】:2021-04-24 21:45:46
【问题描述】:
我使用 TextRazor 库来分析文本并将其保存在文本文件中,但是当我打开文件时它是空的
import os
textrazor.api_key = ""
client = textrazor.TextRazor(extractors=["word","entities", "topics","sentence","words"])
response = client.analyze("Twenty-four isolates (60%) were associated with pneumonia, 14 (35%) with upper respiratory tract infections, and 2 (5%) with bronchiolitis. Cough (82.5%), fever (75%), and malaise (58.8%) ")
for entity in response.entities():
print(entity.id, entity.relevance_score, entity.confidence_score, entity.freebase_types)
cmd = os.popen('ls -w').read() # Récupération de la sortie de ls -a dans la variable cmd
print(cmd) # Affichage de la sortie
with open('monfichier.txt', 'w') as file:
s=str(cmd)
file.write(s)
【问题讨论】:
-
我建议从您的问题中删除您的 API 密钥