python-3.x - 在 google colab 中创建两个新目录并加入它们

标签 python-3.x

我正在使用 google colab python 3,我想使用它在 jupyter notebook 中运行但不在 google colab 中运行的代码

我试过 !mkdir 但我还是不能加入他们

# Create a new directory
base_dir = 'base_dir'
os.mkdir(base_dir)
# create a path to 'base_dir' to which we will join the names of the new folder
# train_dir
train_dir = os.path.join(base_dir, 'train_dir')
os.mkdir(train_dir)

我想加入 base_dir 和 train_dir

最佳答案

也许这行得通:

import tensorflow as tf

#Create a new directory (a folder) in your Drive
tf.gfile.MkDir(base_dir)

#Combine the 2 strings
string = ('base_dir', 'train_dir')
s = ''
train_dir = s.join(string)

#Create the second directory
tf.gfile.MkDir(train_dir)

关于python-3.x - 在 google colab 中创建两个新目录并加入它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54172874/

相关文章:

python - 如何分两个阶段进行 xpath 搜索?

javascript - 您可以使用 Django 框架将 Python 用于前端和后端吗?

python-3.x - 查找特定行的多个列的最大值并将最大列的标题保存到新列中

python - 将 sqlite3.cursor 转换为 int PYTHON

jquery - django.jQuery $ 不是函数消息

python - 为什么 setattr 在绑定(bind)方法上失败

像excel一样的Python字符串序列

Python 3 安装位置

python - Python 中的简单合并排序错误

python - Anaconda:如何彻底删除 Python 3.4?