Skip to content
七月 21, 2010 / wychi

[python] string/unicode issue in traverse file system.

it is very interesting that os.walk() return encoded or unicode string corresponding to your input.

rootPath = ‘R:\\123′
uRootPath = u’R:\\123’
def walk(path):
for root, dirs, files in os.walk(path, topdown=False):
for name in files:
srcFile = os.path.join(root, name)
print type( srcFile )

=====

this post express the concept and behavior very clear.
用 Python 搞定亂七八糟字串

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: