在Python中添加单三引号变量
这可能是最简单的问题,我已经尝试过三重双引号的解决方案。
但根据 Mixpanel 文档,他们传递单三引号,如下所示。
我必须在这里传递我的日期变量。
fromdate = '2022-03-12'
todate = '2022-03-12'
query1 = '''function main() {
return Events({
from_date: fromdate,
to_date: todate,
event_selectors:[
{'event':'Event name'}
]
})
}'''
print(query1)
3
This might be the simplest question, I have tried the solution for triple double-quotes.
But as per Mixpanel documentation, they are passing single triple quotes like below.
I have to pass my date variable here.
fromdate = '2022-03-12'
todate = '2022-03-12'
query1 = '''function main() {
return Events({
from_date: fromdate,
to_date: todate,
event_selectors:[
{'event':'Event name'}
]
})
}'''
print(query1)
3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 f-strings
请注意,您需要将大括号转义为
{{
和}}
。You can use f-strings
Do notice that you need to escape the curly braces as
{{
and}}
.您可以使用“f”前缀字符串在另一个字符串中插入 Python 表达式。
你想要的可能是:
You can use the "f" prefixed strings to be able to interpolate Python expressions in another string.
What you want is probably: