Python: SyntaxError: f-string: expecting '}'Python: SyntaxError: f-string: expecting '}'Python: SyntaxError: f-string: expecting '}'Python: SyntaxError: f-string: expecting '}'
  • 首页
  • 博客
  • 书签
  • 文件
  • 分析
  • 登录

Python: SyntaxError: f-string: expecting '}'

发表 admin at 2023年9月2日
类别
  • Python
标签

这段代码:

tasks = ['markup', 'media', 'script']
print(f'Initializing project with the following tasks:{ ' '.join(tasks) }')

报错:

File "project.py", line 85
print(f'Initializing project with the following tasks:{ ' '.join(tasks) }')

SyntaxError: f-string: expecting '}'

2. 相关原因:

因为f-string使用了两次单引号。

3. 解决办法:

单引号里面使用双引号。

f'Initializing project with the following tasks:{ " ".join(tasks) }'

发表回复 取消回复

要发表评论,您必须先登录。

类别

  • Cat
  • Python
  • Django
  • Database
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • Maths/AI
  • PHP/Wordpress
  • Practice
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • SEO
  • English
  • Games
  • Recipes
  • General
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2023 艾丽卡 Blog support@alaica.com
      ajax-loader