小编Aae*_*ech的帖子

F' 字符串字典时语法无效

当我尝试使用 f'string 字典时,它说语法无效。

def up_low(s):
    d={"upper":0,"lower":0}
    for c in s:
        if c.isupper():
            d["upper"]+=1
            print (f"No. of Upper case characters: {d["upper"]}")
        elif c.islower():
            d["lower"]+=1
            print (f"No. of Lower case characters:{d["lower"]}")
        else:
            pass
Run Code Online (Sandbox Code Playgroud)

它说第 6 行和第 9 行语法无效。

python

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

标签 统计

python ×1