import matplotlib.pyplot 缩进问题

import matplotlib.pyplot indentation problems

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