И затем я могу загрузить его в другую ячейку с таким же идентичным выводом:
CELL_A
Код: Выделить всё
%%capture cap
import matplotlib.pyplot as plt
# Data
x = [1, 2]
y = [3, 4]
# Create a simple plot
plt.plot(x, y)
# Add labels to the axes
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
# Add a title to the plot
plt.title('Simple Plot Example')
# Show the plot
plt.show()
# Save the captured output to a text file
with open('stdout.txt', 'w') as file:
file.write(cap.stdout)
Код: Выделить всё
#@title Reloading CELL_A output
with open('stdout.txt', 'r') as file:
cell_a_out = file.read()
display(cell_a_out)
Подробнее здесь: https://stackoverflow.com/questions/778 ... utput-that