解释:self.stateSpace = [i for i range(self.m * self.n)] [关闭]

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

此代码应该是健身房自定义环境的开始,但是我无法获得以下for循环的语法。我不知道该怎么做。

#importing packages
import numpy as np
import matplotlib.pyplot as plt
#Gr
class GridWorld(object):
    def __init__(self,m,n,magicSquares):
        #m and n for the matrix size m*n
        self.m=m
        self.n=n
        #representing the matrix by a list of zeros of size m*n 
        self.grid(np.zeros(m,n))
        #This one i don't get it ? i thought it was supposed to be the matrix as a whole
        self.stateSpace=[i for i in range]
python for-loop syntax
1个回答
-1
投票

虽然不清楚上面需要解释哪些代码行,但我相信您的问题是关于python中的List Comprehensions,因为这是问题标题的重点。

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