小编Oli*_*ett的帖子

"SyntaxError:关键字arg之后的非关键字arg"使用requests.post()时Python中的错误

response = requests.post("http://api.bf3stats.com/pc/player/", data = player, opt)
Run Code Online (Sandbox Code Playgroud)

在python IDLE中运行此行以测试我遇到的语法错误:关键字arg之后的非关键字arg.

不知道什么事发生在这里.

player并且opt是包含一个单词字符串的变量.

python post arguments

7
推荐指数
2
解决办法
5万
查看次数

Python循环遍历字典以使用另一个字典中的值替换键

我有一本字典,我想将该字典中的所有键更改为另一个字典中的值.

例如:

X = {"apple" : 42}

Y = {"apple" : "Apples"}
Run Code Online (Sandbox Code Playgroud)

转换后:

快译通 X = {"Apples" : 42}

def convert(items, ID):
    for key, value in items.items():
        for keys, values in ID.items():
            if keys == key:
                key = values
    return items
Run Code Online (Sandbox Code Playgroud)

所以我已经编写了上面的代码来执行此操作,但是在执行此函数后,我打印字典并且键没有更改.

python dictionary loops

1
推荐指数
1
解决办法
3887
查看次数

标签 统计

python ×2

arguments ×1

dictionary ×1

loops ×1

post ×1