Whim, did a picture crawler downloader, because no time have to manually set up the picture directory, so Baidu the next Chinese directory establishment method, helpless before a few answers are not completely correct, so here want to integrate under.
In order to set up the Chinese directory, it is of course to find the current directory, two lines
1 Import OS 2 Cur_path = Os.path.abspath (Os.curdir)
In fact, there are several ways to output the current directory, please Baidu, we do not repeat here. The rest is to set up a Chinese directory, in plain language to establish a Chinese directory or coding problems, Python can not directly output Chinese characters, so want to set up a Chinese directory to the Chinese character string encoding as gb2312, the code is as follows
1 import sys 2 reload (SYS) 3 sys.setdefaultencoding ( " utf-8 " ) 4 word = " Chinese blahblah " 5 goal_path = Cur_path + " \\ " + word.encode (" gb2312 " ) 6 Os.mkdir (Goal_path)
The Chinese catalogue has been built here.
Python creates a Chinese folder in the current directory