代码拉取完成,页面将自动刷新
# Script Name : dir_test.py
# Author : Craig Richards
# Created : 29th November 2011
# Last Modified : by- Joshua Covington 05 Oct 2020
# Version : 1.0
# Modifications :
# Description : Tests to see if the directory testdir exists, if not it will create the directory for you if you want it created.
from __future__ import print_function
import os
try:
input = raw_input()
except NameError:
pass
def main():
CheckDir = input("Enter the name of the directory to check : ")
print()
if os.path.exists(CheckDir): # Checks if the dir exists
print("The directory exists")
else:
print("No directory found for " + CheckDir) # Output if no directory
print()
option = input("Would you like this directory create? y/n: ")
if option == 'n':
print("Goodbye")
exit()
if option == 'y':
os.makedirs(CheckDir) # Creates a new dir for the given name
print("Directory created for " + CheckDir)
else:
print("Not an option. Exiting")
exit()
if __name__ == '__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。