导入 matplotlib.pyplot 缩进问题



我是python的新手,想用pyplot尝试一些事情(我的文件名为main.py(。

import matplotlib.pyplot as plt
import numpy as np
if __name__ == '__main__':
data = open("article1.txt", "r")
dict = {}
...
...

这段代码昨天确实完美运行。但是今天,当我启动它时,我收到以下错误:

IndetationError: unexpected indent (transforms.py, line 1)

然后打开一个名为artist.py的文件,并突出显示以下行:

from .transforms import Bbox, IdentityTransform, TransformedBbox, 

我不知道这里发生了什么,如果有人能帮助我解决这个问题,我会很高兴。

你确定你真的在运行好的代码吗?

IndetationError: unexpected inden (transforms.py, line 1)

^^这告诉您在第 1 行的 transforms.py 中存在缩进错误^^


from .transforms import Bbox, IdentityTransform, TransformedBbox, 首先,您应该删除转换前的"."和末尾的"\",如下所示:

from transforms import Bbox, IdentityTransform, TransformedBbox

你说 artist.py 正在开放,这就是为什么我问你是否正在运行好的代码。好像你在跑 artist.py?;D

最新更新