简体   繁体   中英

os.makedirs python AttributeError

i'm having a os library error, and it seems that there aren't much info about it on the net. When i try to create a folder in ubuntu 14.04 using my python script:

from os  import *

ncpath = "lol"

if not path.exists(ncpath):
    makedirs(path,0755)

this error is returned:

  File "/home/user/anaconda2/lib/python2.7/posixpath.py", line 85, in split
    i = p.rfind('/') + 1
AttributeError: 'module' object has no attribute 'rfind'

can someone help me figure out what's going on ?

Here:

makedirs(path,0755)

You are passing the path module itself instead ncpath which is your string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM