是的,Qstring有类似于Python的str.find()的方法,称为indexOf()。它可以用于查找子字符串在字符串中的位置。使用方法如下:

QString str = "Hello world";
int index = str.indexOf("world");

上述代码将返回子字符串“world”在字符串“Hello world”中的位置,即6。如果子字符串不存在,则返回-1。

此外,QString还有其他一些类似于Python的字符串方法,如startsWith()和endsWith(),这些方法可以用于检查字符串是否以特定的子字符串开头或结尾。

QT QString 有么有类似 python的 strfind 查找命令

原文地址: https://www.cveoy.top/t/topic/ck6H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录