python创建文件夹名称_Python如何使用用户输入的名称创建文件夹?

我有一个python脚本,运行该脚本以循环方式截取屏幕截图并保存所有这些图像。但目前,所有的图像都存储在Python35文件夹中。在

因此,我希望用户输入一个文件夹的名称,并用这个名称创建一个。在

我知道使用makedirs函数并通过newpath=r'C:/users/../'指定路径。在

但是如何将用户指定的新文件夹名附加到路径中呢?在

(编辑)这是代码I有:在import openpyxl

import re

import os

import time

from PIL import ImageGrab

import webbrowser

source_excel=input('Enter the source excel file name-> ')

wb=openpyxl.load_workbook(source_excel)

sheet=wb.active

strt=int(input('Enter starting range-> '))

end=int(input('Enter ending range-> '))

#NEED THE CHANGE HERE

foldname=input("Enter a folder name to create where images will be saved")

newpath=r'C:\Users\rnair\AppData\Local\Programs\Python\Python35\'demofile

# Loop to get the link from excel and take the screenshot by opening the browser for each link

for q in range(strt,end):

getme=q,sheet.cell(row=q,column=1).value #get link from excel file

ab=getme[1]

#myopener=Myopen()

rowc=str(strt)

url=ab

webbrowser.open(url) #opens browser for the link fetched

time.sleep(7) # Delay to wait for the page to load completely

im=ImageGrab.grab()

os.chdir(newpath)

im.save("Row"+rowc+".jpg","JPEG") # Saving image to file

strt=strt+1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值