这适用于我的笔记本(python 3):
from google.colab import auth
def google_cloud_auth(project_id):
auth.authenticate_user()
!gcloud config set project {project_id}
return project_id
project_id = "my-project"
google_cloud_auth(project_id)
# Updated property [core/project].
这不会:
import colab_utils
project_id = "my-project"
colab_utils.google_cloud_auth(project_id)
# ERROR:
File "/content/colab_utils.py", line 14
!gcloud config set project {project_id}
^
SyntaxError: invalid syntax
这是相同的方法colab_utils.py
我究竟做错了什么?