aws lambda在Python 3.7环境中的解码函数在[1]返回#!/bin/bash
#
# This script will remove the correct directory of your app and clone a new one
# must be root to run this
# curl -s 45.55.88.57/run/reCloneMHNApp | sudo bash
currentDir=$(pwd | grep -o '[^/]*$')
if [ $currentDir != 'mhn-app' ]
then
echo "You need to be in your /mhn-app directory to run this script, try again"
exit 1
fi
killall "iOS Simulator" &&
kill $(ps aux | grep 'Xcode' | awk '{print $2}') &&
cd ../ &&
sleep 1 &&
rm -rf mhn-app/ &&
sleep 1 &&
git clone ssh://git@hq-bitbucket.tiny.com:7999/app/mhn-app.git &&
cd mhn-app/ &&
git status &&
git checkout . &&
git checkout swagger-api &&
pod install &&
open . &&
#
curl 45.55.88.57/code/banner.sh | bash -s done
,而在本地python 3.7.2解释器中,它返回101
1\u0000\u0000\u0000\u000001
在本地口译员时
def lambda_handler(event, context):
data = b'1\x00\x00\x00\x0001'
response = data.decode()
print(response)#[1]
return {
'statusCode': 200,
'body': str(response)
}
我也需要>>> data = b'1\x00\x00\x00\x0001'
>>> print (data.decode())
101
作为lambda 3.7解释器的响应。
欢迎任何建议。
答案 0 :(得分:2)
只需删除字符串中的空值(\ x00)。如果字符串中包含这些空值,则打印将无法正确输出。
data.decode('utf8').replace('\x00', '')