os.path.join verschluckt angaben?
Verfasst: Donnerstag 25. November 2010, 19:09
Kann mir eventuell jemand folgendes erklären? Denn ich steh grad aufm Schlauch, oder so...
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dst = u'C:\\das\\ziel'
>>> dst
u'C:\\das\\ziel'
>>> src = u'C:\\das\\ziel\\die\\quelle'
>>> src
u'C:\\das\\ziel\\die\\quelle'
>>> path = u'C:\\das\\ziel\\die\\quelle\\und_eben_nochn_ordner'
>>> path
u'C:\\das\\ziel\\die\\quelle\\und_eben_nochn_ordner'
>>> import os
>>> os.path.join(dst, path.replace(src, ''))
u'\\und_eben_nochn_ordner'
>>> os.path.join(dst, path.replace(src, u''))
u'\\und_eben_nochn_ordner'
>>> dst + path.replace(src, '')
u'C:\\das\\ziel\\und_eben_nochn_ordner'