小编stu*_*ent的帖子

python代码在列表和字典中的输出问题

我写了这段代码-

    travel_log = [
    {
      "country": "France",
      "visits": 12,
      "cities": ["Paris", "Lille", "Dijon"]
    },
    {
      "country": "Germany",
      "visits": 5,
      "cities": ["Berlin", "Hamburg", "Stuttgart"]
    },
    ]
    def add_new_country(c,v,citi):
      travel_log.append(f'"country":{c},"visits": {v},"cities": {citi}')

    add_new_country("Russia", 2, ["Moscow", "Saint Petersburg"])
    print(travel_log)
Run Code Online (Sandbox Code Playgroud)

我已附上输出图像 为什么我在列表的最后一个元素中得到 \ 。

python

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

标签 统计

python ×1