gpt4 book ai didi

使用字符串格式运算符的 C++ 字符串替换

转载 作者:太空狗 更新时间:2023-10-29 19:59:56 24 4
gpt4 key购买 nike

<分区>

我是 C++ 的新手,来自 python。我真正怀念的一项功能是字符串格式运算符。我见过很多可以在 printf() 函数中使用它的示例,但是,有时只需替换字符串变量中的占位符就很方便。这是一个使用 mysqldb 模块的 python 示例:

...
stmt = 'INSERT INTO %s(pid, starttime) VALUES("%s","%s")' % ('pids', int(p0.pid), episode[0][1])
cursor.execute(stmt)

你能用 C++ 做类似的事情吗?我没有找到任何谷歌搜索的例子。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com