如何将字符串更改为大写 [英] How to change a string into uppercase

查看:54
本文介绍了如何将字符串更改为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Python 将字符串更改为大写时遇到问题.在我的研究中,我得到了 string.ascii_uppercase 但它不起作用.

I have problem in changing a string into uppercase with Python. In my research, I got string.ascii_uppercase but it doesn't work.

以下代码:

 >>s = 'sdsd'
 >>s.ascii_uppercase

给出这个错误信息:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'ascii_uppercase'

我的问题是:如何在 Python 中将字符串转换为大写?

推荐答案

>>> s = 'sdsd'
>>> s.upper()
'SDSD'

请参阅字符串方法.

这篇关于如何将字符串更改为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆