【问题标题】:Importing a function into another script Indexing error将函数导入另一个脚本索引错误
【发布时间】:2021-10-22 21:28:53
【问题描述】:

我正在将我的一个子函数导入到我的主脚本中,并且不断收到以下信息:

IndexError: 列表索引超出范围

我正在脚本中实现与函数要求相同的函数调用。有谁知道检查函数是否正确导入的方法?

下面是我正在使用的代码示例

    from file_with_function import function

    [output1 output2 output3] = function(roll = 15, pitch = 30, 
    yaw = 45)

    print('Argument List: '+ str(sys.argv))
    rolla = int(sys.argv[1])
    pitcha = int(sys.argv[2])
    yawa = int(sys.argv[3])

    def function(roll = 15 , pitch = 30 , yaw = 45):

     #script is here

     if __name__ =='__main__':
            function(
            roll = rolla,
            pitch = pitcha,
            yaw = yawa)

【问题讨论】:

  • 进入调用这个函数的脚本
  • python3,,,,,,,,
  • 刚刚添加的,,,,,
  • William,如果您共享脚本和文件会很有帮助。谢谢。
  • 刚刚添加了一些谢谢!

标签: python-3.x import


【解决方案1】:

您尝试导入的函数有错误,或者您传递给该函数的数据有问题。我不认为这是一个导入错误,但如果不看代码,我真的帮不了你。

【讨论】:

  • 刚刚上传了一些代码以获得更多说明
猜你喜欢
  • 1970-01-01
  • 2021-12-20
  • 1970-01-01
  • 2018-09-23
  • 2020-09-25
  • 1970-01-01
  • 2019-03-03
  • 2011-01-16
  • 1970-01-01
相关资源
最近更新 更多