You are calling 'step()' even though this environment has already returned done = True. You should always call 'reset()' once you receive 'done = True' -- any further steps are undefined behavior.
时间: 2023-06-27 07:02:51 浏览: 150
这个错误通常是由于在环境已经结束(`done=True`)的情况下继续调用 `step()` 方法导致的。在这种情况下,应该先调用 `reset()` 方法来重置环境,然后再开始新的一轮交互。
例如,在 OpenAI Gym 中,可以采用以下方式避免这个错误:
```python
env.reset()
done = False
while not done:
action = policy(observation)
observation, reward, done, info = env.step(action)
env.close()
```
在这个示例中,我们在每次交互之前检查是否已经完成,并在完成后调用 `reset()` 方法。
相关问题
The specified child already has a parent. You must call removeView() on the child's parent first.
This error message is related to the Android view hierarchy. It occurs when you try to add a view to a parent view, but the child view already has a parent view.
In order to fix this error, you need to make sure that the child view is not already attached to another parent view. You can do this by calling the `removeView()` method on the child's current parent view before adding it to a new parent view.
For example, if you are trying to add a Button view to a LinearLayout, you would need to do the following:
```java
LinearLayout layout = findViewById(R.id.my_linear_layout);
Button button = findViewById(R.id.my_button);
// Check if the button already has a parent view
if (button.getParent() != null) {
// Remove the button from its current parent view
((ViewGroup) button.getParent()).removeView(button);
}
// Add the button to the LinearLayout
layout.addView(button);
```
By removing the child view from its current parent view before adding it to a new parent view, you can avoid the "specified child already has a parent" error.
poi解析docx格式The supplied data appears to be in the OLE2 Format. You are calling
在解析docx格式的word文档时,如果出现"The supplied data appears to be in the OLE2 Format. You are calling the part"的错误提示,通常是因为使用了错误的POI库来处理文档。正确的处理方式是使用XWPFWordExtractor类来解析docx格式的文档。以下是一个示例代码:
```java
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class DocxParser {
public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream("example.docx");
XWPFDocument doc = new XWPFDocument(fis);
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String text = extractor.getText();
System.out.println(text);
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
```
在上述代码中,我们首先使用FileInputStream类读取docx文件,然后使用XWPFDocument类将文件内容加载到内存中。接着,我们使用XWPFWordExtractor类从XWPFDocument对象中提取文本内容,并将其打印到控制台上。
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)