【问题标题】:I need to speed up my code, Also I need to use += i , for sure:for i in nums: sumof += i, its peivets memory block我需要加速我的代码,我还需要使用 += i ,当然:for i in nums: sumof += i, its peivets memory block
【发布时间】:2021-02-01 11:36:52
【问题描述】:

我尝试将我的 argmax 转换为 array.index(max(array)) 我将不胜感激任何帮助。 我需要加快我的代码。 此代码仅适用于一张图片,我将在一分钟内拥有大约 20 张图片。所以这就是为什么我尽量让它更快。

import time
import numpy as np

#tab = [0.061,0.001,0.022,0.002,0.015,0.021,0.066,0.005,0.053,0.018,0.011,0.024,0.052,0.021,0.077,0.010,0.045,0.017,0.016,0.007,0.071,0.167,0.052,0.016,0.017,0.004,0.009,0.014,0.001,0.059,0.018,0.008,0.004,0.009,0.009]#tabK = [0.009,0.003,0.002,0.001,0.157,0.003,0.067,0.005,0.006,0.002,0.012,0.005,0.033,0.002,0.007,0.010,0.001,0.008,0.037,0.008,0.377,0.011,0.043,0.009,0.004,0.002,0.013,0.016,0.004,0.005,0.057,0.013,0.023,0.026,0.018]CATEGORIES = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","R","S","T","U","V","W","X","Y","Z"]
#KOLEJNOSC ZNAKOW W TABLICY JEST ODWROCONA
CATEGORIES = ["0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F","G","H","I","J",
"K","L","M","N","O","P","R","S","T","U",
"V","W","X","Y","Z"]



KR887JJ = [[0.002,0.006,0.004,0.045,0.002,0.017,0.006,0.077,0.001,0.035,0.042,0.005,0.004,0.039,0.001,0.002,0.001,0.008,0.058,0.352,0.002,0.007,0.017,0.004,0.007,0.007,0.007,0.004,0.005,0.009,0.089,0.036,0.053,0.041,0.004],[0.003,0.007,0.005,0.075,0.001,0.020,0.006,0.044,0.002,0.035,0.026,0.004,0.004,0.033,0.001,0.001,0.003,0.008,0.049,0.360,0.002,0.007,0.021,0.005,0.009,0.003,0.008,0.007,0.003,0.014,0.092,0.048,0.058,0.031,0.004],[0.002,0.000,0.025,0.012,0.006,0.002,0.001,0.627,0.006,0.021,0.022,0.008,0.004,0.006,0.004,0.033,0.000,0.006,0.011,0.009,0.002,0.002,0.009,0.000,0.002,0.040,0.007,0.005,0.015,0.000,0.035,0.001,0.008,0.015,0.053],[0.056,0.008,0.023,0.038,0.015,0.007,0.050,0.006,0.412,0.004,0.005,0.027,0.011,0.005,0.021,0.007,0.073,0.024,0.012,0.005,0.013,0.005,0.027,0.003,0.015,0.001,0.005,0.074,0.002,0.022,0.005,0.011,0.002,0.001,0.006],[0.025,0.011,0.025,0.034,0.018,0.027,0.090,0.008,0.258,0.006,0.007,0.026,0.016,0.008,0.026,0.011,0.079,0.030,0.026,0.008,0.018,0.011,0.033,0.003,0.016,0.001,0.003,0.106,0.004,0.021,0.012,0.013,0.003,0.005,0.014],[0.048,0.027,0.019,0.002,0.028,0.002,0.008,0.017,0.041,0.014,0.012,0.022,0.031,0.005,0.045,0.100,0.004,0.031,0.033,0.002,0.029,0.006,0.021,0.032,0.008,0.038,0.317,0.007,0.017,0.004,0.018,0.005,0.003,0.004,0.002],[0.013,0.002,0.002,0.000,0.164,0.001,0.060,0.004,0.006,0.002,0.018,0.003,0.035,0.002,0.008,0.008,0.001,0.008,0.028,0.005,0.383,0.013,0.063,0.010,0.004,0.002,0.014,0.016,0.002,0.005,0.048,0.011,0.028,0.017,0.012]]

[[0.004,0.007,0.005,0.042,0.002,0.014,0.011,0.054,0.002,0.032,0.051,0.005,0.005,0.044,0.001,0.002,0.002,0.008,0.056,0.389,0.003,0.008,0.023,0.005,0.009,0.005,0.009,0.006,0.004,0.010,0.070,0.029,0.049,0.031,0.005],[0.005,0.005,0.005,0.034,0.002,0.006,0.005,0.083,0.002,0.062,0.053,0.004,0.006,0.039,0.001,0.002,0.001,0.008,0.055,0.348,0.002,0.005,0.020,0.005,0.011,0.011,0.018,0.004,0.005,0.008,0.086,0.018,0.055,0.020,0.004],[0.001,0.001,0.024,0.009,0.013,0.003,0.002,0.499,0.006,0.011,0.022,0.011,0.007,0.006,0.006,0.048,0.000,0.008,0.013,0.009,0.004,0.002,0.007,0.000,0.002,0.053,0.009,0.007,0.030,0.000,0.030,0.001,0.009,0.021,0.123],[0.039,0.008,0.029,0.041,0.013,0.008,0.054,0.005,0.369,0.004,0.005,0.023,0.011,0.005,0.020,0.005,0.100,0.022,0.012,0.005,0.012,0.007,0.028,0.002,0.015,0.000,0.003,0.102,0.001,0.021,0.006,0.012,0.002,0.002,0.007],[0.031,0.007,0.018,0.032,0.015,0.017,0.075,0.008,0.365,0.005,0.005,0.028,0.015,0.005,0.022,0.011,0.075,0.027,0.014,0.005,0.020,0.006,0.025,0.002,0.014,0.001,0.004,0.099,0.003,0.016,0.008,0.009,0.002,0.002,0.010],[0.046,0.022,0.022,0.002,0.031,0.003,0.008,0.022,0.047,0.011,0.010,0.039,0.035,0.005,0.048,0.110,0.002,0.028,0.031,0.003,0.029,0.006,0.016,0.022,0.007,0.059,0.289,0.005,0.016,0.003,0.013,0.004,0.002,0.004,0.003],[0.019,0.004,0.002,0.000,0.134,0.004,0.088,0.006,0.004,0.003,0.016,0.007,0.037,0.004,0.016,0.014,0.002,0.014,0.026,0.005,0.342,0.019,0.049,0.024,0.004,0.003,0.021,0.009,0.005,0.009,0.049,0.012,0.017,0.026,0.006]]

[[0.002,0.005,0.005,0.046,0.002,0.014,0.008,0.073,0.002,0.023,0.042,0.004,0.007,0.027,0.001,0.003,0.001,0.006,0.047,0.384,0.005,0.006,0.015,0.003,0.006,0.004,0.011,0.006,0.006,0.005,0.088,0.027,0.066,0.040,0.010],[0.002,0.005,0.005,0.039,0.002,0.009,0.005,0.089,0.001,0.036,0.043,0.004,0.006,0.026,0.001,0.002,0.001,0.006,0.051,0.387,0.003,0.005,0.014,0.003,0.007,0.007,0.014,0.004,0.007,0.005,0.090,0.022,0.064,0.030,0.006],[0.002,0.001,0.014,0.011,0.020,0.005,0.004,0.282,0.005,0.012,0.022,0.011,0.009,0.010,0.008,0.041,0.000,0.017,0.030,0.019,0.009,0.003,0.009,0.000,0.004,0.053,0.010,0.016,0.049,0.000,0.043,0.002,0.017,0.037,0.224],[0.028,0.015,0.029,0.039,0.023,0.020,0.097,0.008,0.239,0.004,0.009,0.021,0.019,0.008,0.017,0.008,0.082,0.023,0.025,0.012,0.020,0.010,0.037,0.003,0.016,0.001,0.003,0.110,0.003,0.019,0.012,0.014,0.004,0.005,0.015],[0.037,0.013,0.035,0.053,0.025,0.022,0.057,0.017,0.250,0.005,0.009,0.037,0.025,0.008,0.029,0.013,0.057,0.029,0.029,0.009,0.015,0.009,0.027,0.002,0.020,0.002,0.006,0.092,0.006,0.012,0.011,0.011,0.003,0.004,0.021],[0.036,0.022,0.024,0.003,0.022,0.004,0.011,0.019,0.069,0.014,0.011,0.035,0.045,0.006,0.057,0.096,0.004,0.037,0.030,0.004,0.039,0.007,0.021,0.018,0.010,0.031,0.256,0.013,0.018,0.003,0.018,0.005,0.004,0.006,0.004],[0.015,0.003,0.002,0.000,0.174,0.004,0.085,0.008,0.005,0.002,0.015,0.008,0.028,0.003,0.013,0.016,0.001,0.015,0.029,0.004,0.357,0.013,0.043,0.017,0.003,0.003,0.017,0.010,0.004,0.007,0.037,0.013,0.015,0.020,0.010]]

[[0.005,0.006,0.006,0.055,0.002,0.017,0.009,0.076,0.003,0.035,0.032,0.007,0.005,0.050,0.001,0.002,0.002,0.011,0.050,0.391,0.002,0.005,0.018,0.003,0.012,0.009,0.009,0.005,0.005,0.012,0.068,0.032,0.032,0.017,0.006],[0.009,0.005,0.007,0.064,0.002,0.022,0.009,0.040,0.003,0.030,0.026,0.010,0.006,0.069,0.001,0.001,0.004,0.011,0.040,0.379,0.002,0.009,0.021,0.005,0.017,0.007,0.009,0.005,0.003,0.034,0.063,0.035,0.029,0.017,0.006],[0.001,0.001,0.014,0.011,0.011,0.004,0.003,0.458,0.004,0.012,0.023,0.010,0.007,0.009,0.006,0.039,0.000,0.012,0.016,0.014,0.005,0.003,0.007,0.000,0.002,0.052,0.008,0.009,0.039,0.000,0.036,0.001,0.013,0.032,0.139],[0.042,0.012,0.023,0.029,0.043,0.015,0.111,0.010,0.235,0.004,0.009,0.036,0.023,0.010,0.018,0.010,0.039,0.029,0.024,0.012,0.025,0.009,0.041,0.003,0.019,0.002,0.005,0.084,0.004,0.018,0.013,0.012,0.004,0.005,0.023],[0.030,0.008,0.017,0.033,0.011,0.020,0.103,0.009,0.289,0.004,0.006,0.030,0.022,0.007,0.021,0.011,0.108,0.031,0.013,0.008,0.020,0.006,0.023,0.002,0.018,0.001,0.004,0.102,0.005,0.012,0.007,0.007,0.002,0.003,0.009],[0.034,0.024,0.018,0.003,0.025,0.005,0.008,0.025,0.053,0.010,0.008,0.045,0.036,0.006,0.050,0.119,0.002,0.035,0.028,0.003,0.029,0.005,0.014,0.017,0.007,0.060,0.275,0.006,0.019,0.002,0.013,0.004,0.003,0.006,0.005],[0.016,0.004,0.002,0.000,0.130,0.003,0.080,0.005,0.004,0.003,0.017,0.005,0.038,0.002,0.015,0.014,0.002,0.011,0.027,0.004,0.378,0.016,0.051,0.019,0.004,0.002,0.020,0.012,0.004,0.006,0.040,0.013,0.023,0.020,0.008]]

[[0.006,0.004,0.007,0.052,0.002,0.012,0.005,0.066,0.002,0.043,0.036,0.007,0.007,0.051,0.001,0.001,0.002,0.008,0.037,0.401,0.002,0.008,0.017,0.004,0.013,0.010,0.014,0.004,0.004,0.016,0.077,0.021,0.038,0.018,0.006],[0.001,0.001,0.012,0.008,0.013,0.004,0.002,0.462,0.004,0.011,0.022,0.008,0.006,0.006,0.006,0.052,0.000,0.012,0.018,0.012,0.005,0.002,0.007,0.000,0.002,0.046,0.009,0.009,0.040,0.000,0.039,0.002,0.012,0.031,0.136],[0.004,0.003,0.007,0.042,0.001,0.008,0.005,0.060,0.002,0.062,0.050,0.005,0.004,0.053,0.000,0.001,0.002,0.006,0.033,0.422,0.001,0.008,0.017,0.004,0.011,0.007,0.010,0.003,0.002,0.013,0.065,0.024,0.045,0.017,0.003],[0.029,0.015,0.032,0.058,0.018,0.013,0.067,0.012,0.287,0.006,0.010,0.025,0.016,0.007,0.017,0.009,0.059,0.023,0.026,0.011,0.016,0.006,0.033,0.003,0.017,0.001,0.006,0.118,0.004,0.014,0.009,0.012,0.004,0.003,0.012],[0.056,0.011,0.024,0.034,0.027,0.015,0.065,0.013,0.271,0.006,0.007,0.062,0.028,0.013,0.026,0.014,0.030,0.039,0.027,0.011,0.019,0.006,0.031,0.003,0.027,0.005,0.009,0.061,0.006,0.014,0.011,0.006,0.002,0.004,0.016],[0.041,0.020,0.022,0.002,0.019,0.004,0.007,0.024,0.046,0.016,0.008,0.051,0.036,0.006,0.051,0.109,0.002,0.030,0.027,0.003,0.024,0.005,0.015,0.017,0.008,0.067,0.286,0.005,0.015,0.003,0.014,0.003,0.002,0.005,0.003],[0.014,0.003,0.002,0.000,0.106,0.007,0.079,0.007,0.004,0.003,0.014,0.010,0.041,0.004,0.013,0.011,0.001,0.014,0.031,0.007,0.377,0.022,0.049,0.017,0.004,0.003,0.014,0.009,0.004,0.009,0.050,0.013,0.016,0.034,0.008]]

[[0.008,0.004,0.008,0.064,0.001,0.018,0.009,0.041,0.003,0.043,0.035,0.008,0.005,0.076,0.001,0.001,0.004,0.009,0.037,0.382,0.001,0.011,0.024,0.005,0.015,0.006,0.007,0.005,0.002,0.030,0.057,0.031,0.029,0.017,0.004],[0.002,0.004,0.004,0.044,0.001,0.012,0.005,0.068,0.001,0.043,0.052,0.003,0.005,0.030,0.001,0.002,0.001,0.007,0.041,0.350,0.003,0.007,0.019,0.005,0.007,0.004,0.011,0.005,0.003,0.007,0.099,0.035,0.076,0.038,0.004],[0.001,0.001,0.015,0.011,0.009,0.004,0.002,0.517,0.004,0.012,0.028,0.007,0.005,0.007,0.005,0.035,0.000,0.011,0.014,0.012,0.005,0.003,0.010,0.000,0.002,0.030,0.006,0.009,0.029,0.000,0.039,0.002,0.016,0.034,0.114],[0.026,0.010,0.036,0.064,0.011,0.009,0.052,0.010,0.360,0.004,0.007,0.022,0.015,0.005,0.017,0.006,0.067,0.019,0.017,0.008,0.013,0.006,0.026,0.002,0.015,0.001,0.004,0.121,0.003,0.011,0.006,0.010,0.003,0.002,0.011],[0.044,0.017,0.027,0.037,0.024,0.016,0.079,0.010,0.259,0.006,0.009,0.032,0.023,0.009,0.022,0.012,0.064,0.031,0.026,0.010,0.019,0.007,0.034,0.004,0.021,0.002,0.007,0.086,0.005,0.018,0.011,0.011,0.003,0.003,0.011],[0.033,0.013,0.021,0.002,0.014,0.003,0.006,0.023,0.033,0.015,0.009,0.048,0.040,0.007,0.056,0.098,0.002,0.032,0.023,0.003,0.023,0.006,0.013,0.015,0.009,0.069,0.331,0.005,0.018,0.002,0.012,0.003,0.002,0.005,0.003],[0.017,0.004,0.002,0.000,0.096,0.008,0.095,0.007,0.004,0.003,0.013,0.012,0.045,0.006,0.017,0.013,0.002,0.016,0.029,0.007,0.360,0.023,0.045,0.023,0.005,0.004,0.018,0.008,0.005,0.010,0.042,0.011,0.013,0.032,0.007]]

[[0.007,0.004,0.007,0.082,0.002,0.023,0.009,0.029,0.003,0.024,0.024,0.008,0.006,0.062,0.001,0.001,0.005,0.009,0.032,0.391,0.002,0.012,0.020,0.005,0.016,0.004,0.006,0.006,0.002,0.037,0.061,0.041,0.033,0.019,0.006],[0.004,0.004,0.008,0.078,0.001,0.013,0.005,0.059,0.002,0.044,0.041,0.006,0.005,0.052,0.001,0.001,0.002,0.008,0.036,0.366,0.001,0.010,0.015,0.003,0.011,0.008,0.008,0.005,0.004,0.015,0.074,0.035,0.045,0.023,0.007],[0.001,0.001,0.013,0.010,0.015,0.006,0.004,0.299,0.004,0.011,0.021,0.011,0.009,0.010,0.009,0.044,0.000,0.021,0.023,0.017,0.008,0.004,0.007,0.000,0.003,0.056,0.008,0.014,0.056,0.000,0.040,0.002,0.016,0.039,0.217],[0.021,0.011,0.022,0.060,0.018,0.026,0.090,0.014,0.234,0.005,0.011,0.025,0.016,0.009,0.015,0.011,0.052,0.030,0.029,0.015,0.019,0.007,0.030,0.003,0.016,0.001,0.003,0.134,0.006,0.013,0.011,0.014,0.004,0.005,0.020],[0.031,0.012,0.027,0.036,0.023,0.020,0.053,0.018,0.269,0.006,0.008,0.029,0.036,0.007,0.029,0.021,0.046,0.030,0.028,0.009,0.023,0.007,0.027,0.003,0.020,0.002,0.010,0.098,0.010,0.009,0.016,0.009,0.004,0.005,0.018],[0.036,0.019,0.017,0.002,0.027,0.004,0.009,0.027,0.063,0.012,0.008,0.045,0.035,0.006,0.050,0.140,0.002,0.036,0.030,0.003,0.031,0.004,0.017,0.016,0.007,0.055,0.239,0.007,0.018,0.002,0.014,0.004,0.003,0.006,0.004],[0.018,0.004,0.002,0.000,0.186,0.004,0.107,0.005,0.005,0.003,0.010,0.008,0.041,0.004,0.017,0.018,0.001,0.012,0.034,0.004,0.300,0.014,0.036,0.018,0.004,0.004,0.020,0.010,0.005,0.008,0.049,0.009,0.011,0.020,0.008]]

start = time.time()

for sing in KR887JJ: 
    print(CATEGORIES[np.argmax(sing)])

    #print(CATEGORIES[sing.index(max(sing))])




def list_mean(nums):
    sumof = 0
    num_of = len(nums)
    mean = 0
    for i in nums:
        sumof += i 
    mean = sumof / num_of
    return float(mean)


end = time.time()

print(f"Runtime of the program is {end - start}")

我也 100% 需要这部分,因为我在 nums 中:
总和 += i。像这样的迭代不会占用大量内存,因为它不断计数而不是具有大块内存和平的迭代。 提前致谢!

【问题讨论】:

  • 我不明白你的问题。你在使用 numpy 数组吗?为什么你认为array.index(max(array)) 会更快?这意味着您使用的是list?
  • 如果您提供真实示例数据,这将非常有帮助,其中包含您的代码应该做什么的完整描述,包括您输入的相应输出
  • numpy 数组没有 index 方法。您的变量名称和问题应该反映这种差异。例如alist.index....

标签: python numpy argmax


【解决方案1】:

np.argmax 并不比 array.index(np.max(array)) 慢,但是 list_mean 可以更高效:如果你想要一个完整的 python 实现,你可以使用

sum(nums)/len(nums)

甚至更高效:

np.mean(nums)

(您已经使用过数组)

【讨论】:

  • 对不起,我的代码运行得更快,但我真的需要加快速度。
  • 我进行迭代,因为它占用的空间更少:for i in nums: sumof += i.如您所见,我有很多数据
  • 你能显示更完整的代码吗?事实上,很难理解你的代码是做什么的,上下文等......可以肯定的是,优化问题不是来自 argmax,它可能更大。
  • 据我所知,你没有那么多数据..
【解决方案2】:

或多或少: 进口时间 将 numpy 导入为 np

#KOLEJNOSC ZNAKOW W TABLICY JEST ODWROCONA 类别 = ["0","1","2","3","4","5","6","7","8","9","A","B" ,"C","D","E","F","G","H","I","J","K","L","M","N"," O","P","R","S","T","U","V","W","X","Y","Z"]

KR887JJ = [[0.002,0.006,0.004,0.045,0.002,0.017,0.006,0.077,0.001,0.035,0.042,0.005,0.004,0.039,0.001,0.002,0.001,0.078,0.02,0.02,0.02,0.02,0.02 ,0.017,0.004,0.007,0.007,0.007,0.004,0.005,0.009,0.089,0.036,0.053,0.041,0.004],[0.003,0.007,0.005,0.075,0.001,0.0450,0.026,0.03,0.026,0.03 ,0.004,0.004,0.033,0.001,0.001,0.003,0.008,0.049,0.360,0.002,0.007,0.021,0.005,0.009,0.003,0.008,0.007,0.003,0.014,0.052,0.038,0.052,0.018,0.052,0.018 [0.0.0.000,0.025,0.012,0.006,0.002,0.001,0.627,0.006,0.021,0.022,0.008,0.004,0.006,0.004,0.033,0.006,0.006,0.011,0.009,0.002,0.002,0.009,0.000,0.002 ,0.040,0.007,0.005,0.015,0.000,0.035,0.001,0.008,0.015,0.053],[0.056,0.008,0.023,0.038,0.015,0.007,0.050,0.006,0.412,0.024,0.01,0.007,0.01,0.01 ,0.021,0.007,0.073,0.024,0.012,0.005,0.013,0.005,0.027,0.003,0.015,0.001,0.005,0.074,0.002,0.022,0.005,0.011,0.002],0.001,5,0.002,0.001,5,0.026 ,0.034,0.018,0.027,0.090,0.008,0.258,0.006,0.007,0.026,0.016,0.008,0.026,0.011,0.079,0.030,0.026,0.008,0.018,0.011,0.033 ,0.003,0.016,0.001,0.003,0.106,0.004,0.021,0.012,0.013,0.003,0.005,0.014],[0.048,0.027,0.019,0.002,0.028,0.002,0.021,0.027,0.01,0.027,0.01 ,0.031,0.005,0.045,0.100,0.004,0.031,0.033,0.002,0.029,0.006,0.021,0.032,0.008,0.038,0.317,0.007,0.017,0.004,0.018,0.005,0.018,0.005,0.003] ,0.0.0.002,0.0.0.164,0.001,0.060,0.004,0.006,0.002,0.018,0.003,0.035,0.002,0.008,0.008,0.001,0.008,0.028,0.005,0.0.0.0.0.013,0.0.0.0.0.0.0.013,0.0.0.0.010.004,0.002 ,0.014,0.016,0.002,0.005,0.048,0.011,0.028,0.017,0.012]] [[0.004,0.007,0.005,0.042,0.002,0.014,0.011,0.054,0.002,0.032,0.051,0.005,0.005,0.044,0.001,0.002,0.002,0.008,0.056,0.005,0.023,0.005,0.0203, 0.009,0.005,0.009,0.006,0.004,0.010,0.070,0.029,0.049,0.031,0.005],[0.005,0.005,0.005,0.034,0.002,0.006,0.005,0.083,0.052,3,0.006,0.006 0.039,0.001,0.002,0.001,0.008,0.055,0.348,0.002,0.005,0.020,0.005,0.011,0.011,0.018,0.004,0.005,0.008,0.086,0.018,0.055,0,0.01,0.055,0,0.020,0.004, 0.024,0.009,0.013,0.003,0.002,0.499,0.006,0.011,0.022,0.011,0.007,0.006,0.006,0.048,0.006,0.008,0.013,0.009,0.004,0.002,0.007,0.000,0.002,0.053,0.009, 0.007,0.030,0.000,0.030,0.001,0.009,0.021,0.123],[0.039,0.008,0.029,0.041,0.013,0.008,0.054,0.005,0.369,0.004,0.001,0.0.023,0.0201,0.0.023,0.0201 0.100,0.022,0.012,0.005,0.012,0.007,0.028,0.002,0.015,0.000,0.003,0.102,0.001,0.021,0.006,0.012,0.002,0.002,0.007],7,0.01,8,0.0302 0.017,0.075,0.008,0.365,0.005,0.005,0.028,0.015,0.005,0.022,0.011,0.075,0.027,0.014,0.005,0.020,0.006,0.025,0.002,0.014, 0.001,0.004,0.099,0.003,0.016,0.008,0.009,0.002,0.002,0.010],[0.046,0.022,0.022,0.002,0.031,0.003,0.008,0.022,0.047,0.03,0.035,0.035 0.048,0.110,0.002,0.028,0.031,0.003,0.029,0.006,0.016,0.022,0.007,0.059,0.289,0.005,0.016,0.003,0.013,0.004,0.002,0.004,0,0.0024,[0.004,0,0.003] 0.000.0.134,0.004,0.088,0.006,0.004,0.003,0.016,0.007,0.037,0.004,0.016,0.014,0.002,0.014,0.026,0.005,0.342,0.019,0.049,0.024,0.004,0.003,0.021,0.009, 0.005,0.009,0.049,0.012,0.017,0.026,0.006]] [[0.002,0.005,0.005,0.046,0.002,0.014,0.008,0.073,0.002,0.023,0.042,0.004,0.007,0.027,0.001,0.003,0.001,0.006,0.047,0.0384,0.010,0.005,0.056 0.006,0.004,0.011,0.006,0.006,0.005,0.088,0.027,0.066,0.040,0.010],[0.002,0.005,0.005,0.039,0.002,0.009,0.005,0.089,0.0.003,0.006,0.003,0.0064 0.026,0.001,0.002,0.001,0.006,0.051,0.387,0.003,0.005,0.014,0.003,0.007,0.007,0.014,0.004,0.007,0.005,0.090,0.022,0.064,0,0.02,0.064,0,0.020,[0.02] 0.014,0.0.0.0.020,0.005,0.004,0.282,0.005,0.012,0.022,0.0.011,0.009,0.010,0.008,0.041,0.010,0.017,0.030,0.019,0.0.0.003,0.009,0.000.004,0.053,0.010, 0.016,0.049,0.000,0.043,0.002,0.017,0.037,0.224],[0.028,0.015,0.029,0.039,0.023,0.020,0.097,0.008,0.239,0.004,0.009,9,00.021,8,0.0108,0.0017 0.082,0.023,0.025,0.012,0.020,0.010,0.037,0.003,0.016,0.001,0.003,0.110,0.003,0.019,0.012,0.014,0.004,0.005,0.015],0.027,0.0513,0.023,0.0513 0.022,0.057,0.017,0.250,0.005,0.009,0.037,0.025,0.008,0.029,0.013,0.057,0.029,0.029,0.009,0.015,0.009,0.027,0.002,0.020, 0.002,0.006,0.092,0.006,0.012,0.011,0.011,0.003,0.004,0.021],[0.036,0.022,0.024,0.003,0.022,0.004,0.011,0.019,0.061,0.03,0.04,0.0456 0.057,0.096,0.004,0.037,0.030,0.004,0.039,0.007,0.021,0.018,0.010,0.031,0.256,0.013,0.018,0.003,0.018,0.005,0.004,0.006,0,0.0023] 0.000.0.174,0.004,0.085,0.008,0.005,0.002,0.015,0.008,0.028,0.003,0.013,0.016,0.001,0.015,0.029,0.004,0.0.017,0.013,0.0.0.0.017,0.003,0.003,0.017,0.01010, 0.004,0.007,0.037,0.013,0.015,0.020,0.010]] [[0.005,0.006,0.006,0.055,0.002,0.017,0.009,0.076,0.003,0.035,0.032,0.007,0.005,0.050,0.001,0.002,0.002,0.011,0.050,0.0.391,0.0108,0.003,0.0102 0.012,0.009,0.009,0.005,0.005,0.012,0.068,0.032,0.032,0.017,0.006],[0.009,0.005,0.007,0.064,0.002,0.022,0.009,0.040,0.02,0.0166 0.069,0.001,0.001,0.004,0.011,0.040,0.379,0.002,0.009,0.021,0.005,0.017,0.007,0.009,0.005,0.003,0.034,0.063,0.035,0.0029,0,0.01,[0.017] 0.014,0.011,0.011,0.004,0.003,0.458,0.004,0.012,0.023,0.010,0.007,0.009,0.006,0.039,0.009,0.012,0.016,0.014,0.005,0.003,0.007,0.000,0.002,0.052,0.008, 0.009,0.039,0.000,0.036,0.001,0.013,0.032,0.139],[0.042,0.012,0.023,0.029,0.043,0.015,0.111,0.010,0.235,0.004,0.003,0.01,0.0108,0.0108 0.039,0.029,0.024,0.012,0.025,0.009,0.041,0.003,0.019,0.002,0.005,0.084,0.004,0.018,0.013,0.012,0.004,0.005,0.023],0.011,0.013,0.0303 0.020,0.103,0.009,0.289,0.004,0.006,0.030,0.022,0.007,0.021,0.011,0.108,0.031,0.013,0.008,0.020,0.006,0.023,0.002,0.018, 0.001,0.004,0.102,0.005,0.012,0.007,0.007,0.002,0.003,0.009],[0.034,0.024,0.018,0.003,0.025,0.005,0.008,0.025,0.053,0.0.010,0.03066 0.050,0.119,0.002,0.035,0.028,0.003,0.029,0.005,0.014,0.017,0.007,0.060,0.275,0.006,0.019,0.002,0.013,0.004,0.003,0.006,0,0.002] 0.0.0.130,0.0.003,0.080,0.005,0.004,0.003,0.017,0.005,0.038,0.002,0.015,0.014,0.002,0.011,0.027,0.004,0.011,0.027,0.004,0.019,0.016,0.051,0.019,0.004,0.002,0.020,0.012, 0.004,0.006,0.040,0.013,0.023,0.020,0.008]] [[0.006,0.004,0.007,0.052,0.002,0.012,0.005,0.066,0.002,0.043,0.036,0.007,0.007,0.051,0.001,0.001,0.002,0.008,0.037,0.0401,0.0108,0.04,0.0108 0.013,0.010,0.014,0.004,0.004,0.016,0.077,0.021,0.038,0.018,0.006],[0.001,0.001,0.012,0.008,0.013,0.004,0.002,0.461,0.02,0.02,0.006 0.006,0.006,0.052,0.000,0.012,0.018,0.012,0.005,0.002,0.007,0.000,0.002,0.046,0.009,0.009,0.040,0.000,0.039,0.002,0.306,0,0.03,0.031 0.0.0.0.042,0.001,0.008,0.005,0.060,0.002,0.062,0.050,0.005,0.004,0.053,0.000,0.001,0.002,0.006,0.033,0.0.0.0.001,0.008,0.017,0.004,0.011,0.007,0.0.010, 0.003,0.002,0.013,0.065,0.024,0.045,0.017,0.003],[0.029,0.015,0.032,0.058,0.018,0.013,0.067,0.012,0.287,0.006,0.010,6,0.0.025,0.0107,0.0107 0.059,0.023,0.026,0.011,0.016,0.006,0.033,0.003,0.017,0.001,0.006,0.118,0.004,0.014,0.009,0.012,0.004,0.003,0.012],0.022,0.0714 0.015,0.065,0.013,0.271,0.006,0.007,0.062,0.028,0.013,0.026,0.014,0.030,0.039,0.027,0.011,0.019,0.006,0.031,0.003,0.027, 0.005,0.009,0.061,0.006,0.014,0.011,0.006,0.002,0.004,0.016],[0.041,0.020,0.022,0.002,0.019,0.004,0.007,0.024,0.046,0.0.016,0.0306,0.056,0.0306 0.051,0.109,0.002,0.030,0.027,0.003,0.024,0.005,0.015,0.017,0.008,0.067,0.286,0.005,0.015,0.003,0.014,0.003,0.002,0.005,0,0.0023,[0.005,0,0.003] 0.000.0.106,0.007,0.079,0.007,0.004,0.003,0.014,0.010,0.041,0.004,0.013,0.011,0.001,0.014,0.031,0.007,0.014,0.022,0.049,0.017,0.022,0.049,0.017,0.004,0.003,0.017,0.004,0.003,0.014,0.009, 0.004,0.009,0.050,0.013,0.016,0.034,0.008]] [[0.008,0.004,0.008,0.064,0.001,0.018,0.009,0.041,0.003,0.043,0.035,0.008,0.005,0.076,0.001,0.001,0.004,0.009,0.037,0.051,0.0201,0.011,0.0201 0.015,0.006,0.007,0.005,0.002,0.030,0.057,0.031,0.029,0.017,0.004],[0.002,0.004,0.004,0.044,0.001,0.012,0.005,0.068,0.051,0.053,0.053,0.001,0.003 0.030,0.001,0.002,0.001,0.007,0.041,0.350,0.003,0.007,0.019,0.005,0.007,0.004,0.011,0.005,0.003,0.007,0.099,0.035,0.076,0,0.01,0.076,0.010,[0.008] 0.015,0.011,0.009,0.004,0.002,0.517,0.004,0.012,0.028,0.007,0.005,0.007,0.005,0.035,0.007,0.011,0.014,0.012,0.0.005,0.003,0.012,0.005,0.003,0.010,0.000.002,0.030,0.006, 0.009,0.029,0.000,0.039,0.002,0.016,0.034,0.114],[0.026,0.010,0.036,0.064,0.011,0.009,0.052,0.010,0.360,0.004,0.007,0.0.022,0.0107,0.0.022,0.0106 0.067,0.019,0.017,0.008,0.013,0.006,0.026,0.002,0.015,0.001,0.004,0.121,0.003,0.011,0.006,0.010,0.003,0.002,0.011],7,0.024,0.037 0.016,0.079,0.010,0.259,0.006,0.009,0.032,0.023,0.009,0.022,0.012,0.064,0.031,0.026,0.010,0.019,0.007,0.034,0.004,0.021, 0.002,0.007,0.086,0.005,0.018,0.011,0.011,0.003,0.003,0.011],[0.033,0.013,0.021,0.002,0.014,0.003,0.006,0.023,0.033,9.00.015,0.040,0.004,0.004 0.056,0.098,0.002,0.032,0.023,0.003,0.023,0.006,0.013,0.015,0.009,0.069,0.331,0.005,0.018,0.002,0.012,0.003,0.002,0.005,0,0.002,0.005,0,0.0024] 0.0000.096,0.008,0.095,0.007,0.004,0.003,0.013,0.012,0.045,0.006,0.017,0.013,0.002,0.016,0.029,0.007,0.016,0.023,0.045,0.023,0.005,0.004,0.018,0.008, 0.005,0.010,0.042,0.011,0.013,0.032,0.007]] [[0.007,0.004,0.007,0.082,0.002,0.023,0.009,0.029,0.003,0.024,0.024,0.008,0.006,0.062,0.001,0.001,0.005,0.009,0.032,0.012,0.0202,0.012,0.0202, 0.016,0.004,0.006,0.006,0.002,0.037,0.061,0.041,0.033,0.019,0.006],[0.004,0.004,0.008,0.078,0.001,0.013,0.005,0.059,4,0.0.01,0.004,0.004,0.004,0.006 0.052,0.001,0.001,0.002,0.008,0.036,0.366,0.001,0.010,0.015,0.003,0.011,0.008,0.008,0.005,0.004,0.015,0.074,0.035,0.045,0,0.023,0.045,0,0.023, 0.013,0.010,0.015,0.006,0.004,0.299,0.004,0.011,0.021,0.011,0.009,0.010,0.009,0.044,0.0.0.021,0.023,0.0.0.0.008,0.004,0.007,0.008,0.004,0.007,0.000,0.003,0.056,0.008, 0.014,0.056,0.000,0.040,0.002,0.016,0.039,0.217],[0.021,0.011,0.022,0.060,0.018,0.026,0.090,0.014,0.234,0.005,0.011,6,0.01,0.025,0.011,0.015,0.0115 0.052,0.030,0.029,0.015,0.019,0.007,0.030,0.003,0.016,0.001,0.003,0.134,0.006,0.013,0.011,0.014,0.004,0.005,0.020],0.021,0.036 0.020,0.053,0.018,0.269,0.006,0.008,0.029,0.036,0.007,0.029,0.021,0.046,0.030,0.028,0.009,0.023,0.007,0.027,0.003,0.020, 0.002,0.010,0.098,0.010,0.009,0.016,0.009,0.004,0.005,0.018],[0.036,0.019,0.017,0.002,0.027,0.004,0.009,0.027,0.063,0.00.012,0.0305,0.004,0.03056 0.050,0.140,0.002,0.036,0.030,0.003,0.031,0.004,0.017,0.016,0.007,0.055,0.239,0.007,0.018,0.002,0.014,0.004,0.003,0.006,0,0.0024,[0.006,0,0.004] 0.000.0.186,0.004,0.0.107,0.005,0.005,0.003,0.010,0.008,0.041,0.004,0.017,0.018,0.001,0.0.017,0.034,0.001,0.0.017,0.034,0.004,0300,0.014,0.036,0.018,0.004,0.004,0.020,0.010, 0.005,0.008,0.049,0.009,0.011,0.020,0.008]]

开始 = time.time()

在 KR887JJ 中唱歌: 打印(类别[sing.index(max(sing))])

def list_mean(nums):

sumof, len = 0, 0
for i in nums:      
    sumof += i
#len += 1
return sumof / len

end = time.time()

print(f"程序的运行时间是{end - start}")

【讨论】:

    猜你喜欢
    • 2020-09-21
    • 2014-07-03
    • 2011-07-27
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多