Skip to content

Instantly share code, notes, and snippets.

@ShimanoN
Created January 27, 2023 12:01
Show Gist options
  • Save ShimanoN/6c61db754192da1eb753b20c5e7034ec to your computer and use it in GitHub Desktop.
Save ShimanoN/6c61db754192da1eb753b20c5e7034ec to your computer and use it in GitHub Desktop.
20230127.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8f1007da-9232-4e7e-9274-b794554850c0",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter the directory where you want to create the folder: C:/Users/OneDrive/jyupyter練習\n",
"Enter the name of the folder you want to create: 20230127\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully created the directory C:/Users/OneDrive/jyupyter練習\\20230127\n"
]
}
],
"source": [
"import os\n",
"\n",
"directory = input(\"Enter the directory where you want to create the folder: \")\n",
"folder_name = input(\"Enter the name of the folder you want to create: \")\n",
"\n",
"path = os.path.join(directory, folder_name)\n",
"\n",
"try:\n",
" os.mkdir(path)\n",
" print(f\"Successfully created the directory {path}\")\n",
"except OSError:\n",
" print(f\"Creation of the directory {path} failed\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd46608f-176d-42e1-abba-a5ee89d05c07",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment