【问题标题】:In 32nd iteration FileNotFoundError: [Errno 2]在第 32 次迭代中 FileNotFoundError: [Errno 2]
【发布时间】:2019-10-18 13:15:25
【问题描述】:

我正在创建散点图并将它们保存到循环中的文件中,然后在第 23 次迭代中它给了我这个:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\hrdinhal\\Desktop\\OPTIX\\Fines B\\Slike\\Fines B mids and Mids Rush/Drag.png'

我该如何解决?

def scatter(i):
    while i < (len(df1.columns) - 3):
        xi = df1.iloc[:, i]
        plt.scatter(xi, df1.iloc[:, 1])
        plt.title('Fines B mids and {}'.format(df1.columns[i]))
        plt.ylabel('Fines B mids')
        plt.xlabel(df1.columns[i])
        plt.savefig('C:\\Users\\hrdinhal\\Desktop\\OPTIX\\Fines B\\Slike\\Fines B mids and {}.png'.format(df1.columns[i]))
        i = i+1
        plt.show()
    return 
scatter(3)

【问题讨论】:

    标签: python-3.x matplotlib seaborn


    【解决方案1】:

    您是否尝试使用调试器执行您的程序? 一步一步的执行会有所帮助。

    很可能,df1.columns[i] 不会返回您期望的文件名 Fines B mids and Mids Rush/Drag.png 的有效部分 Python 为您提供了理解该问题所需的全部信息。 故障线路:

    plt.savefig('C:\\Users\\hrdinhal\\Desktop\\OPTIX\\Fines B\\Slike\\Fines B mids and {}.png'.format(df1.columns[i]))
    

    错误的文件名:

    `Fines B mids and Mids Rush/Drag.png`
    

    【讨论】:

    • 不,我没有,我会试试的。
    猜你喜欢
    • 2014-11-13
    • 2022-08-03
    • 2019-08-06
    • 1970-01-01
    • 2019-09-20
    • 2020-11-08
    • 2020-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多