TypeError:无法将str转换为字节

2024-03-29 12:26:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我以为在python中可以合并两个字符串,我可能会在我的代码片段中遗漏一些东西:

def create_set(feature, value):
  return b'{"type":"set","feature":'+feature+',"value":'+value+'}'

on = create_set("main.power", "on")

Tags: 字符串代码returnvaluemainondeftype