python - f-strings 应该在 Python 3.4 中工作吗?

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

这应该在 Python 3.4 中工作吗:

>>> a='tttt'

>>> print(f'a的值为{a}')

最佳答案

我写了一个(糟糕的)thing通过编码技巧启用它们:

首先:

pip install future-fstrings

然后替换编码 cookie(如果你有的话)然后砰! python<3.6

中的 f-strings
# -*- coding: future_fstrings -*-
thing = 'world'
print(f'hello {thing}')

运行时:

$ python2.7 main.py
hello world

关于python - f-strings 应该在 Python 3.4 中工作吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38865348/

相关文章:

python - 使用 python 和 zeromq 分发任务

python - 优步 API : request_ride with sandbox_mode=True is throwing error message

python - 如何在 Clickhouse-driver 中获取 JSON 格式的数据

python - 在特定迭代或检查点将模型加载/恢复到 tensorflow

android - 如何获取word中的特殊字符及其点击事件

python - 如何通过在一个函数中包含所有类型的填充来处理缺失值?

从西里尔字母转换为拉丁字母 C

java - 将 Java 字符串转换为字节数组

python - 计算每组行的平均值

python - 如何获取dataframe的值?