【问题标题】:Why is that Python 3 IDE in some sites doesn't support f string function? [duplicate]为什么某些站点中的 Python 3 IDE 不支持 f 字符串函数? [复制]
【发布时间】:2018-07-20 15:32:38
【问题描述】:

f 字符串函数

print(f"{theString}")

比这更容易打印字符串

print("{}".format(theString))

但某些站点中的 Python 3 编译器不支持此功能。是否有一些特定版本的 Python 支持此功能。

编辑:Hackerrank.com 像其他一些网站一样只是提到它是 Python 3 或 2 并且没有特定版本

【问题讨论】:

  • 它应该适用于版本 >= 3.6
  • This is the PEP that indtroduced f-strings 注意“Python-Version”是3.6
  • 谷歌搜索“python f string”会带你到this作为第一个命中,它说明了它适用的python版本。
  • 仅供参考,您可以通过import sys; print(sys.version)查看版本
  • 为什么它被否决了? :o

标签: python python-3.x f-string


【解决方案1】:

Python 3.6 introduced f-strings。任何 python 3.6 或更高版本都将支持此功能。

【讨论】:

  • image 那么可能该网站使用的版本低于 3.6。
  • @abhijithvijayan 是的!这就是每个人都在说的 ;)
猜你喜欢
  • 1970-01-01
  • 2017-05-10
  • 1970-01-01
  • 1970-01-01
  • 2011-08-02
  • 2021-02-11
  • 1970-01-01
  • 2016-05-22
相关资源
最近更新 更多