当前位置:网站首页>如何向 google colab 快速上传文件
如何向 google colab 快速上传文件
2022-07-24 17:53:00 【samll-guo】
分为如下几个步骤:
Step#1 连接到 google 云盘:
from google.colab import drive
drive.mount('/content/drive',force_remount = True)执行成功后,会显示: Mounted at /content/drive
Step#2 进入子目录 My Drive:
import os
root_dir = "/content/drive/My Drive/"
os.chdir(root_dir)确认:
显示: /content/drive/MyDrive
Step#3 建立子目录 "Colab_Notebooks" :
!mkdir "Colab_Notebooks"
Step#4 进入子目录:
import os
os.chdir("Colab_Notebooks")Step#5 再建立下一级及目录 "Project_folder":
!mkdir "Project_folder"
Step#6 进入刚建好的下一级子目录:
import os
root_dir = "/content/drive/My Drive/"
project_folder = "Colab_Notebooks/Project_folder/"
os.chdir(root_dir + project_folder)Step#7 查看现在所在的目录:
!pwd显示结果:/content/drive/My Drive/Colab_Notebooks/Project_folder
Step#8 现在,开始上传文件:
from google.colab import files
files.upload()
执行这一段代码后,会显示一个选择文件的对话窗口。
我可以上传我的文件: myfunctions.py
此文件我已经在我的本地C盘准备好了。选择这个文件后,就会自动上传。
在我的 myfunctions.py ,中有如下内容:
def sum_two(num_1, num_2):
result = num_1 + num_2
return resultStep#9 现在,我可以进行跨文件的函数调用:
import myfunctions
result = myfunctions.sum_two(100,200)
print (result)显示结果: 300
边栏推荐
猜你喜欢

使用Prometheus+Grafana监控MySQL性能指标

使用matplotlib模拟线性回归

ShardingSphere数据库读写分离
![[leetcode] 30. Concatenate substrings of all words](/img/21/3965532a31553cfe6edf64ca5de3f4.png)
[leetcode] 30. Concatenate substrings of all words

Array learning navigation

C # print reports using fastreport.net

快速完成intelij idea的单元测试JUnit4设置

C language custom types - Enumeration

Getaverse,走向Web3的远方桥梁

NPM install reported -4058 error
随机推荐
Definition and storage of adjacency table and adjacency storage of directed graph and undirected graph
C language custom type explanation - Consortium
mac数据库管理软件Navicat Premium Essentials Mac
使用matplotlib模拟线性回归
Mac database management software Navicat premium essentials mac
还在从零开始搭建项目?这款升级版快速开发脚手架值得一试!
Pay close attention! List of the latest agenda of 2022 open atom open source Summit
Goodbye Navicat! This open source database management tool has a cooler interface!
Huawei machine test - topic core test point
Tensorflow introductory tutorial (38) -- V2 net
Internship report 1 - face 3D reconstruction method
C language to achieve a static version of the address book
Openlayers: point aggregation effect
实习报告1——人脸三维重建方法
Trends of semiconductor industry
微信朋友圈的高性能复杂度分析
ShardingSphere数据库读写分离
【网络安全】网站中间件存在的解析漏洞
Six ways for JS to implement inheritance
Quickly complete the unit test junit4 setting of intelij idea