Skip to Content
Menu
This question has been flagged
4326 Views

I got an error : OSError: [Errno 2] No such file or directory: '/Users/Downloads'

What is wrong in this code?


 import random, os
a = random.randint(1, 9999)
name = 'filename' + str(a * 7) + '.txt'
print '>>', a
ROOT = os.path.abspath(os.sep)
filepath = os.path.join(ROOT, name)
os.chdir(filepath)
file = open(filepath, 'w')

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 17
2782
1
Jan 23
3845
1
Mar 21
17191
1
Mar 15
3648
6
Sep 22
63706