小编Roy*_*Dai的帖子

AttributeError:'bytes' 对象没有属性 'encode'

尝试将代码从 python2 导入到 python 3 并发生此问题

    <ipython-input-53-e9f33b00348a> in aesEncrypt(text, secKey)
     43 def aesEncrypt(text, secKey):
     44     pad = 16 - len(text) % 16
---> 45     text = text.encode("utf-8") + (pad * chr(pad)).encode("utf-8")
     46     encryptor = AES.new(secKey, 2, '0102030405060708')
     47     ciphertext = encryptor.encrypt(text)
Run Code Online (Sandbox Code Playgroud)

AttributeError:'bytes' 对象没有属性 'encode'

如果我删除.encode("utf-8")错误是“无法将 str 连接到字节”。显然pad*chr(pad)似乎是一个字节串。它不能使用encode()

    <ipython-input-65-9e84e1f3dd26> in aesEncrypt(text, secKey)
     43 def aesEncrypt(text, secKey):
     44     pad = 16 - len(text) % 16
---> 45     text = text.encode("utf-8") + (pad * chr(pad))
     46     encryptor = …
Run Code Online (Sandbox Code Playgroud)

python python-2to3

5
推荐指数
1
解决办法
3万
查看次数

如何修复“make (e=2): 系统找不到指定的文件。”

我想使用 mingW32_make.exe 在命令提示符下编译 C 代码。错误信息显示

rm -f obj/*.o
process_begin: CreateProcess(NULL, rm -f obj/*.o, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:11: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)

makefile如下所示

CC=gcc
INC_DIR=../include
LIBS=-lregex
ODIR=obj
_OBJ=main.o BVPA.o BVPA-cube.o BVPA-cif.o BVPA-hk.o BVPA-path.o BVPA-math.o BVPA-cmd.o BVPA-gui.o BVPA-vesta.o MT19937AR.o
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))
TARGET=../bin/BVPA_win.exe
CFLAGS=-I$(INC_DIR) -Wall -g

all: $(TARGET)
    rm -f $(ODIR)/*.o

$(TARGET): $(OBJ)
    $(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(ODIR)/%.o: %.c
    $(CC) $(CFLAGS) -c -o $@ $^

clean:
    rm …
Run Code Online (Sandbox Code Playgroud)

makefile mingw32

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

makefile ×1

mingw32 ×1

python ×1

python-2to3 ×1