Python- 编码 base64 打印新行
Python- encode base64 print new line
我想尝试用 base64
加密我的 python 代码。
但是当我使用 \n
时出现错误:
print("hello
IndentationError: unexpected indent
这是我使用的代码:
import base64
def encode(data):
try:
# Standard Base64 Encoding
encodedBytes = base64.b64encode(data.encode("utf-8"))
return str(encodedBytes, "utf-8")
except:
return ""
def decode(data):
try:
message_bytes = base64.b64decode(data)
return message_bytes.decode('utf-8')
except:
return ""
your_code = encode("""
print("hello \n world")
""")
exec(decode(your_code))
我可以使用两次 print()
函数而不是 \n
但是有没有办法使用 \n
?
希望你能帮帮我
首先,您必须删除 your_code 部分中的缩进。其次,您必须将 \n
替换为 \n
import base64
def encode(data):
try:
# Standard Base64 Encoding
encodedBytes = base64.b64encode(data.encode("utf-8"))
return str(encodedBytes, "utf-8")
except:
return ""
def decode(data):
try:
message_bytes = base64.b64decode(data)
return message_bytes.decode('utf-8')
except:
return ""
your_code = encode("""
print("hello \n world")
""")
exec(decode(your_code))
我想尝试用 base64
加密我的 python 代码。
但是当我使用 \n
时出现错误:
print("hello
IndentationError: unexpected indent
这是我使用的代码:
import base64
def encode(data):
try:
# Standard Base64 Encoding
encodedBytes = base64.b64encode(data.encode("utf-8"))
return str(encodedBytes, "utf-8")
except:
return ""
def decode(data):
try:
message_bytes = base64.b64decode(data)
return message_bytes.decode('utf-8')
except:
return ""
your_code = encode("""
print("hello \n world")
""")
exec(decode(your_code))
我可以使用两次 print()
函数而不是 \n
但是有没有办法使用 \n
?
希望你能帮帮我
首先,您必须删除 your_code 部分中的缩进。其次,您必须将 \n
替换为 \n
import base64
def encode(data):
try:
# Standard Base64 Encoding
encodedBytes = base64.b64encode(data.encode("utf-8"))
return str(encodedBytes, "utf-8")
except:
return ""
def decode(data):
try:
message_bytes = base64.b64decode(data)
return message_bytes.decode('utf-8')
except:
return ""
your_code = encode("""
print("hello \n world")
""")
exec(decode(your_code))