Foxtable(狐表)用户栏目专家坐堂 → 怎样将下面的python代码转换为foxtable的代码


  共有2817人关注过本帖树形打印复制链接

主题:怎样将下面的python代码转换为foxtable的代码

帅哥哟,离线,有人找我吗?
lxy060669
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:168 积分:2609 威望:0 精华:0 注册:2012/10/16 22:38:00
怎样将下面的python代码转换为foxtable的代码  发帖心情 Post By:2018/7/24 21:51:00 [显示全部帖子]

请教老师,怎样将下面的代码转换为在foxtable中运行的代码?


#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import time
import json
import hashlib
import base64


def main():
    x_appid = '123456'
    api_key = '852d33s93fdd33sasas'
    url = 'http://api.xfyun.cn/v1/service/v1/image_identify/face_verification'
    x_time = str(int(time.time()))
    param = {'auto_rotate': True}
    param = json.dumps(param)
    x_param = base64.b64encode(param.encode('utf-8'))
    m2 = hashlib.md5()
    m2.update(str(api_key + x_time + str(x_param,'utf-8')).encode('utf-8'))
    x_checksum = m2.hexdigest()
    x_header = {
        'X-Appid': x_appid,
        'X-CurTime': x_time,
        'X-CheckSum': x_checksum,
        'X-Param': x_param,
    }
    with open(r'c:/imag1', 'rb') as f:
        f1 = f.read()
    with open(r'c:/imag2', 'rb') as f:
        f2 = f.read()
    f1_base64 = str(base64.b64encode(f1), 'utf-8')
    f2_base64 = str(base64.b64encode(f2), 'utf-8')
    data = {
        'first_image': f1_base64,
        'second_image': f2_base64,
            }
    req = requests.post(url, data=data, headers=x_header)
    result = str(req.content, 'utf-8')
    print(result)
    return


if __name__ == '__main__':
    main()

 回到顶部