开发者

Adding Keyboard input to Directories [closed]

开发者 https://www.devze.com 2023-03-27 16:35 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 9 years ago.

Improve this question

I want to create a directory but I also want to add Keyboard input. Specifically, I want the user to chose the directory name, and location, and then it displays the name and location that the user entered.

Directory:

#!/usr/bin/pyth开发者_如何学编程on
import os

# Create a directory that the user choses when and where
os.mkdir()

Keyboard Input:

filename = raw_input('Filename:')
print('You Entered the Filename:'), filename

Figured it out!!!!!

Thanks everyone but I figured it out!

    import os

    filename = raw_input('Enter Filename:')
    os.mkdir(filename)
    print('Filename Entered'), filename


>>> import os
>>> os.curdir
'.'
>>> filename = raw_input('Filename:')
Filename:mydir
>>> os.mkdir(filename)
>>> os.listdir(os.curdir)
['mydir']
0

精彩评论

暂无评论...
验证码 换一张
取 消