问题描述
PASS examples/67099526/module2.test.js (11.508 s)
67099526
✓ should initialize module1 correctly (8819 ms)
✓ should handle error (18 ms)
console.log
error
at new Module2 (examples/67099526/module2.js:8:15)
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 33.33 | 100 |
module2.js | 100 | 100 | 33.33 | 100 |
------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed,1 total
Tests: 2 passed,2 total
Snapshots: 0 total
Time: 13.743 s
这是我返回的数据
def get_remote_file_binary_data(self,filename,connection_string = ""):
file_data = None
tmp_file_path = copyfile.make_temp_path()
try:
if connection_string:
print("connection string is: ",connection_string)
source_file = copyfile.join(connection_string,filename)
else:
source_file = filename
copyfile.copyfile(source_file,tmp_file_path)
tmp_file = open(tmp_file_path,"rb")
file_data = tmp_file.read()
tmp_file.close()
finally:
os.remove(tmp_file_path)
return file_data
b"PK\x03\x04\x14\x00\x01\x00\x08\x00Fu\x87RR\xa6cpr\x00\x00\x00z\x00\x00\x00\x0c\x00\x00\x00fake_xml.xml)\xe0H\x86]\x83\xd2\xb8\\\xe2\x10\x95f\xde\xa6\x83|&\xa5\x99VwOS\x19\xea\xdb}\xee1[\xe0\x0f'0:C|6u2\xe4\xa6\xbcc\x8e\xdb\xd16(\x1d?\xba\x98Vp\x11\xb5\x06\xe8\xdcn\x0b\xc5I'B\x83#W\xac\xe5*+t\xa6\xa9\xd5\x85\x04\x86+{\xad\xe1\x8b{\xbf\x88L\xc4\xff\xa9=\x18\x9di\xa96Y$3\xfa\x98\x9c\x10\x99\n\x80PG\x9c\xd0GPK\x01\x02?\x00\x14\x00\x01\x00\x08\x00Fu\x87RR\xa6cpr\x00\x00\x00z\x00\x00\x00\x0c\x00$\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00fake_xml.xml\n\x00
\x00\x00\x00\x00\x00\x01\x00\x18\x00\x89R~\x1a\xe6+\xd7\x01
\xe3\xf8\x1a\xe6+\xd7\x01T\xb5N\x1a\xe6+\xd7\x01PK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00^\x00\x00\x00\x9c\x00\x00\x00\x00\x00"
zip_file = self.get_remote_file_binary_data(zip_filename,connection_str)
解决方法
IntStream src ="apple".chars();
String a =src.mapToObj(s -> {
if (s == 97) {
return "aFbcr";
} else if (s == 101) {
return "eFbcr";
}
return String.valueOf((char) (s));
}).collect(Collectors.joining());
System.out.println(a);
输出:
import io
from zipfile import ZipFile
bites = b"PK\x03\x04\x14\x00\x01\x00\x08\x00Fu\x87RR\xa6cpr\x00\x00\x00z\x00\x00\x00\x0c\x00\x00\x00fake_xml.xml)\xe0H\x86]\x83\xd2\xb8\\xe2\x10\x95f\xde\xa6\x83|&\xa5\x99VwOS\x19\xea\xdb}\xee1[\xe0\x0f'0:C|6u2\xe4\xa6\xbcc\x8e\xdb\xd16(\x1d?\xba\x98Vp\x11\xb5\x06\xe8\xdcn\x0b\xc5I'B\x83#W\xac\xe5*+t\xa6\xa9\xd5\x85\x04\x86+{\xad\xe1\x8b{\xbf\x88L\xc4\xff\xa9=\x18\x9di\xa96Y$3\xfa\x98\x9c\x10\x99\n\x80PG\x9c\xd0GPK\x01\x02?\x00\x14\x00\x01\x00\x08\x00Fu\x87RR\xa6cpr\x00\x00\x00z\x00\x00\x00\x0c\x00$\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00fake_xml.xml\n\x00 \x00\x00\x00\x00\x00\x01\x00\x18\x00\x89R~\x1a\xe6+\xd7\x01 \xe3\xf8\x1a\xe6+\xd7\x01T\xb5N\x1a\xe6+\xd7\x01PK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00^\x00\x00\x00\x9c\x00\x00\x00\x00\x00"
print(ZipFile(io.BytesIO(bites)).filelist[0])