byte

can only concatenate str (not “bytes”) to str

僤鯓⒐⒋嵵緔 提交于 2020-08-27 06:32:22
问题 import socket import os user_url = input("Enter url: ") host_name = user_url.split("/")[2] mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect((host_name, 80)) cmd = 'GET ' + user_url + ' HTTP/1.0\r\n\r\n'.encode() mysock.send(cmd) while True: data = mysock.recv(512) if len(data) < 1: break print(data.decode(),end='\n') mysock.close() For some reason im gettin this error Enter url: http://data.pr4e.org/romeo.txt 7 mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM

Byte array to excel workbook

让人想犯罪 __ 提交于 2020-08-27 06:27:51
问题 I am trying to convert a byte array to an excel workbook. When I do this with Response.BinaryWrite(renderedBytes); it works fine and the file is as expected. But when I try to do it with this which I found online: private Object ByteArrayToObject(byte[] arrBytes) { MemoryStream memStream = new MemoryStream(); BinaryFormatter binForm = new BinaryFormatter(); memStream.Write(arrBytes, 0, arrBytes.Length); memStream.Seek(0, SeekOrigin.Begin); Object obj = (Object)binForm.Deserialize(memStream);