请输入一个字符串:,并用函数judgeStr(str)编译Python六个字符,判断输入的字符串中是否含有Python字段,要求不区分大小写 Python代码
时间: 2023-11-19 19:08:55 浏览: 37
```python
def judgeStr(str):
if 'python' in str.lower():
return True
else:
return False
s = input("请输入一个字符串:")
if judgeStr(s):
print("输入的字符串中含有Python字段")
else:
print("输入的字符串中不含有Python字段")
```
相关问题
请输入字符串:,并用函数judgeStr(str)判断输入的字符串中是否含有Python字段,要求不区分大小写。 python代码
```python
def judgeStr(str):
if "python" in str.lower():
return True
else:
return False
input_str = input("请输入字符串:")
if judgeStr(input_str):
print("输入的字符串中包含Python字段")
else:
print("输入的字符串中不包含Python字段")
```
请输入一个字符串,编写函数judgeStr(str)判断输入的字符串中是否含有Python字段,要求不区分大小写 Python代码
```python
def judgeStr(str):
if "python" in str.lower():
return True
else:
return False
```
使用lower()函数将字符串转换为小写,然后在小写字符串中查找是否包含"python"字符串即可。如果包含则返回True,否则返回False。
相关推荐
![.zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)