为什么在kaggle中导入字符串给出错误代码“没有名为‘strings’的模块

问题描述 投票:0回答:1

尝试在 Kaggle Notebook 中导入字符串。 收到错误代码“没有名为‘strings’的模块

还尝试使用 -> !pip install 字符串进行安装 出现错误 - 子进程退出并出现错误

string-install-error import string error

我希望导入字符串,以便我可以调用 string.find() 命令。谢谢你

python string module kaggle longest-substring
1个回答
0
投票

也许我误解了,但你不需要安装字符串。它带有Python。您也不需要导入它。它是 Python 标准字符串方法的一部分。只需使用

str.find()

myString = "Hello world! This is a string!"
index = myString.find("world")
print("Index of 'world':", index)

© www.soinside.com 2019 - 2024. All rights reserved.