코드
def unpack_archive(input_filename, output_foldername):
filename, ext = os.path.splitext(input_filename)
file = open(input_filename, "rb")
for i in range(0, len(files) - 1):
filename = str(files[i][0])
offset = files[i][1]
size = files[i + 1][1] - offset
method = files[i][2]
output_filename = os.path.join(output_foldername, filename)
output_path = os.path.dirname(output_filename)
outfile = open(output_filename, "wb")
outfile.write(data)
outfile.close()
print "x x %d %s" % (offset, size, method, filename)
>>>
Traceback (most recent call last):
File "unpack_vf.py", line 266, in <module>
main()
File "unpack_vf.py", line 18, in main
unpack_archive(args.input_filename, args.output_foldername)
File "unpack_vf.py", line 146, in unpack_archive
outfile = open(output_filename, "wb")
IOError: [Errno 22] invalid mode ('wb') or filename: 'output\\\x83O\x83\x89\x83t\x83B\x83b\x83N\\0_\x94w\x8ci\\0
게임파일 뽑는소스인데 문제가 유니코드 오류때문에 io가 먹통
encoding="utf-8"를 쓰면된다고해서
outfile = open(output_filename, "wb", encoding="utf-8")
이것도 해봤는데
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfc in position 193: invalid start byte
또다른 문제를 하나더만들어옴....
파이썬 유니코드가 원래 병신이야
http://www.dan.co.jp/~dankogai/pyconjp2012/python.html
이거봐라. 파이썬3는 내부문자열을 유니코드로 했긴했는데 그것도 완전하지 못하고. 대부분의 문자열이 아스키인마당에 메모리낭비 성능 낭비라고 말많음.
한자텍스트를 저장하는건데 방법없는건가
텍스트를 ANSI가아닌 utf8로 저장하면 해결될일