可以使用count()方法來計算字符串中特定字符出現的次數。例如:
```python
string = "Hello, World!"
char = "l"
count = string.count(char)
print(f"The character '{char}' appears {count} times in the string.")
```
這將輸出:
The character 'l' appears 3 times in the string.
億速云公眾號
手機網站二維碼
Copyright ? Yisu Cloud Ltd. All Rights Reserved. 2018 版權所有
廣州億速云計算有限公司粵ICP備17096448號-1 粵公網安備 44010402001142號增值電信業務經營許可證編號:B1-20181529