str()

来源:互联网 发布:116114是什么软件 编辑:程序博客网 时间:2024/05/16 23:48
str()

It looks like you're really getting the hang of string methods in Python. In case you're getting a bit bored (and we know adjusting string capitalization isn't the most exciting thing in the world), try the str() method on for size!

The str() method returns a string containing a nicely printable representation of whatever you put between the parentheses. It makes strings out of non-strings! For example,

str(2)

would turn 2 into "2".

Two steps here:

  1. Create a variable pi and set it to3.14 on line 4.
  2. Call str(pi) on line 5, after theprint keyword.
原创粉丝点击