Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have problem in changing a string into uppercase with Python.

(我在使用Python将字符串更改为大写时遇到问题。)

In my research, I got string.ascii_uppercase but it doesn't work.

(在我的研究中,我得到了string.ascii_uppercase但它不起作用。)

The following code:

(以下代码:)

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

Gives this error message:

(给出此错误消息:)

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

My question is: how can I convert a string into uppercase in Python?

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

  ask by gadss translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
298 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

See String Methods .

(请参阅字符串方法)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...