导入matplotlib.pyplot缩进问题

问题描述 投票:-2回答:1

我是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, \

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

python matplotlib indentation
1个回答
1
投票

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

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

^^这告诉您在transforms.py第1行^^处有缩进错误

from .transforms import Bbox, IdentityTransform, TransformedBbox, \ 首先你应该删除'。'在变换之前和'\'在最后,如下:

from transforms import Bbox, IdentityTransform, TransformedBbox

而且你说arts.py正在打开,这就是为什么我在问你是不是在运行好的代码。好像你在运行artist.py? ; d

© www.soinside.com 2019 - 2024. All rights reserved.