如何在Jupyter Lab中运行.py文件?


当前文件夹:

  • t.ipython
  • test.py

test.py:

print("Hello, SageMaker studio lab!")

在Jupyter Lab中运行.py文件有两种方法

1. 将文件导入ipython的cell中

示例代码:

%load test.py

运行结果:

2. 直接运行.py文件

示例代码:

%run test.py

运行结果: