找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2017|回复: 2

[求助] 使用任意数量关键字实参出错

1

主题

2

帖子

2

积分

贫民

积分
2
王诗玙 发表于 2018-8-11 15:48:26 | 显示全部楼层 |阅读模式
求助,照着书上打的代码,但就是运行不出来def bulid_profile(first, last, **user_info):
    profile = {}
    profile['first_name'] = first
    profile['last_name'] = last
    for key, value in user_info.items():
        profile[key] = value
    return profile

user_profile = bulid_profile('albert','einstein',location='princeton',field='physics')
print(user_profile)



py3中提示

  File "C:/Users/Desktop/temp.py", line 7
    def bulid_profile(first, last, **user_info):
                                               ^
SyntaxError: invalid character in identifier


谢谢各位大神



回复

使用道具 举报

0

主题

956

帖子

956

积分

圣骑士

积分
956
sheeboard 发表于 2018-8-12 10:05:57 | 显示全部楼层
代码能运行的,注意中英文标点。
回复 支持 反对

使用道具 举报

1

主题

2

帖子

2

积分

贫民

积分
2
王诗玙  楼主| 发表于 2018-8-12 10:27:21 | 显示全部楼层
谢谢大神!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表