社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

bumblebee

bumblebee 最近回复了
6 年前
回复了 bumblebee 创建的主题 » RabbitMQ中一个具有多个路由密钥的交换或多个有效交换

你可以继续你的第一个方法。宣布 exchange Direct Exchange ,它需要 queue 名称为 routing key . 一个 能够将自身绑定到多个队列。此外,交换的任务是将消息路由到队列。绑定多个队列不会降低RabbitMQ的效率。

6 年前
回复了 bumblebee 创建的主题 » 在python中读取Json

尝试使用 json 包裹

内容 file.json

{"image":{"width":750,"height":1127,"orientation":1},"objects":[{"type":"face","boundingBox":{"x":132,"y":180,"height":619,"width":513},"landmarks":{"faceContour":[[162,375],[162,440],[165,504],[175,568],[193,628],[226,686],[265,740],[313,784],[373,799],[436,793],[494,758],[543,712],[586,660],[616,601],[631,534],[639,468],[645,400]],"noseBridge":[[387,396],[385,441],[381,485],[378,532]],"noseBall":[[322,547],[350,560],[380,572],[412,563],[442,554]],"eyebrowRight":[[419,348],[466,329],[516,325],[564,339],[595,377]],"eyebrowLeft":[[197,358],[224,325],[269,315],[316,325],[358,347]],"eyeRight":[[448,419],[479,404],[510,405],[539,416],[511,425],[480,424]],"eyeRightCenter":[[495,416]],"eyeLeft":[[242,402],[269,393],[299,396],[329,412],[297,414],[267,413]],"eyeLeftCenter":[[284,405]],"mouthOuter":[[269,596],[310,598],[349,598],[379,606],[411,601],[456,606],[502,609],[456,663],[412,684],[378,687],[345,680],[307,652]],"mouthInner":[[284,603],[349,610],[379,615],[411,613],[487,614],[412,652],[379,656],[348,648]]},"attributes":{"gender":"male","genderConfidence":0.8385,"age":24,"ageConfidence":0.8419,"emotion":"happiness","emotionConfidence":1.0,"emotionsAll":{"neutral":0.0,"sadness":0.0,"disgust":0.0,"anger":0.0,"surprise":0.0,"fear":0.0,"happiness":1.0},"pose":{"pitch":-5.7105,"roll":0.2941,"yaw":1.8646},"race":{"asian":0.0002,"black":0.0001,"white":0.9989},"eyewear":{"sunglasses":0.0,"glasses":0.0},"hair":{"color":{"blond":0.0,"black":0.9994,"brown":0.0},"cut":{"short":0.9999,"long":0.0,"bald":0.0},"facial":{"beard":0.0,"mustache":0.0,"stubble":0.2543}},"frontal":true}},{"type":"person","boundingBox":{"x":20,"y":60,"height":1053,"width":696}}],"requestId":"1239be0c782440bd828cee21dbc2baa1"}

代码:

import json

with open('file.json', 'rb') as fp:
    json_data = json.load(fp)

print(json_data['objects'][0]['attributes']['emotionsAll']['neutral'])
6 年前
回复了 bumblebee 创建的主题 » 为什么我的元音去除功能不起作用?(python 2.7)[副本]

你有 return for-a循环中的语句,这就是为什么您的代码就是您的循环只执行一次的原因。把它放在循环之外,代码就可以正常工作了。

def anti_vowel(string):
    for t in string:
        if(t.lower()=='a' or t.lower()=='e' or t.lower()=='i' or t.lower()=='u'):
            string.replace(t, " ")
        print "test"
    print string
    return string

为了替换元音字符,您不能替换现有变量,因为Python中的字符串是不可变的。你可以试试这个

def anti_vowel(string):
    for t in string:
        if(t.lower()=='a' or t.lower()=='e' or t.lower()=='i' or t.lower()=='u'):
            string=string.replace(t, " ")
        print "test"
    print string
    return string