我在尝试更改目录时不断收到以下错误。任何人都可以帮助解决错误以及如何解决这个问题?
CODE SNIPPET: -
print "changing dir..."
print "BUILDDIR: " + BuildDir
os.chdir(BuildDir)
print "Done changing dir..."
错误: -
changing dir...
BUILDDIR: /local/mnt/workspace/username/AU_LINUX_ANDROID_CHO_3.5.04.03.00.003.047_msm8216/
Traceback (most recent call last):
File "Main.py", line 682, in <module>
flist = fd.readlines()
File "Main.py", line 654, in main
picked_gerrits = []
File "Main.py", line 126, in RepoSync
TypeError: must be encoded string without NULL bytes, not str
答案 0 :(得分:0)
很难说无法重现。尝试:
'/'.join(map(str.strip, BuildDir.split('/')))
如果不是google brought me:
import os, re
_split = re.compile(r'[\0%s]' % re.escape(''.join(
[os.path.sep, os.path.altsep or ''])))
def secure_filename(path):
return _split.sub('', path)
print '/%s/' % '/'.join([secure_filename(x) for x in BuildDir.split('/') if x])