麻耶win 2022-04-23 17:38 采纳率: 0%
浏览 141
已结题

Python中碰到这个错误不知道怎么解决

from functools import reduce

from celery_task.utils import mongo_client
from celery_task.config import mongo_conf


def tag_relation(weibo_data: dict, tag_task_id: str, user_mark_data: dict):
    """
    处理话题人物关系网的函数
    :param user_mark_data: 用户分类数据
    :param weibo_data:微博数据
    :param tag_task_id:话题任务
    :return:
    """
    node_list = list()
    link_list = list()
    weibo_list = reduce(lambda x, y: x if y in x else x + [y], [[], ] + weibo_data['data'])
    screen_name_set = set(i['screen_name'] for i in weibo_list)
    relation_data = list()
    for screen_name in screen_name_set:
        at_users_list = list()
        user_id = 0
        hot_count = 0
        for weibo in weibo_list:
            if weibo.get('screen_name') == screen_name:
                at_users_list.extend(weibo.get('at_users'))
                hot_count += int(weibo.get('hot_count'))
                user_id = weibo['user_id']
        relation_data.append({'screen_name': screen_name,
                              'user_id': user_id,
                              'at_users': at_users_list,
                              'hot_count': hot_count
                              }
                             )
    for data in relation_data:
        category = -1
        for user_mark in user_mark_data.get('data'):
            if user_mark.get('user_id') == data['user_id']:
                category = user_mark.get('category')
                break
        node = {'category': category, 'name': data['screen_name'], 'userId': data['user_id'],
                'value': int(data['hot_count'])}
        node_list.append(node)
        for i in data['at_users']:
            link = {'source': data['screen_name'], 'target': i, 'weight': data['at_users'].count(i)}
            if link not in link_list:
                link_list.append(link)
            if i not in screen_name_set:
                node = {'category': -1, 'name': i, 'userId': None,
                        'value': int(data['hot_count'])}
                node_list.append(node)
                screen_name_set.add(i)
            else:
                for node_item in node_list:
                    if node_item['name'] == i:
                        node_item['value'] += int(data['hot_count'])
                        break
    query_by_task_id = {'tag_task_id': tag_task_id}
    update = {
        "$set": {'nodes_list': node_list, 'links_list': link_list, 'categories': user_mark_data.get('categories')}}
    mongo_client.db[mongo_conf.RELATION].update_one(query_by_task_id, update)
    mongo_client.db[mongo_conf.CHARACTER].update_one(query_by_task_id, {'$set': {'detail': node_list}})


if __name__ == '__main__':
    data = mongo_client.db[mongo_conf.BLOG].find_one({'tag_task_id': 'afe59eaa4a9bc41147700ae1b90e7dba'})
    tag_relation(data, 'afe59eaa4a9bc41147700ae1b90e7dba')


报错
D:\Anaconda\envs\python37\python.exe "D:\PyCharm\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 63639 --file D:/Work/YQFX_System/yqfx_system/code/back_end/celery_task/tag_task/tag_relaton_task.py
Connected to pydev debugger (build 213.6777.50)
Traceback (most recent call last):
  File "D:\PyCharm\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\PyCharm\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/Work/YQFX_System/yqfx_system/code/back_end/celery_task/tag_task/tag_relaton_task.py", line 72, in <module>
    tag_relation(data, 'afe59eaa4a9bc41147700ae1b90e7dba')
TypeError: tag_relation() missing 1 required positional argument: 'user_mark_data'

Process finished with exit code 1


  • 写回答

3条回答 默认 最新

  • A Python 萌新花花 2022-04-23 17:51
    关注

    你的tag_relation()少传了一个参数

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月8日
  • 创建了问题 4月23日

悬赏问题

  • ¥15 反激PWM控制芯片调研
  • ¥15 Python for loop减少运行时间
  • ¥15 fluent模拟物质浓度udf
  • ¥15 Collection contains no element matching the predicate
  • ¥20 冻品电商平台的搜索是怎么实现的
  • ¥15 如何搞一个可以控制、显示马达频率
  • ¥15 WPF动态创建页面内容
  • ¥15 如何对TBSS的结果进行统计学的分析已完成置换检验,如何在最终的TBSS输出结果提取除具体值及如何做进一步相关性分析
  • ¥15 SQL数据库操作问题
  • ¥15 Matlab安装yalmip和cplex功能安装失败