Python大写字母小写字母
时间: 2023-11-05 13:04:23 浏览: 55
将字符串转换为大写:
```python
str.upper()
```
将字符串转换为小写:
```python
str.lower()
```
示例:
```python
str = "Hello World!"
print(str.upper()) # 输出: HELLO WORLD!
print(str.lower()) # 输出: hello world!
```
相关问题
Python 大写字母转小写字母
可以使用 Python 内置函数 `lower()` 将大写字母转换为小写字母。例如:
```python
s = 'HELLO WORLD'
print(s.lower()) # 输出 'hello world'
```
在上面的例子中,我们将字符串 `s` 中的所有大写字母转换为小写字母,并将结果打印出来。
python小写字母转大写字母
可以使用字符串的 upper() 方法将小写字母转换为大写字母,例如:
```python
s = "hello world"
s_upper = s.upper()
print(s_upper) # 输出 "HELLO WORLD"
```