我想尝试用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))