热线电话:13121318867

登录
2019-07-02 阅读量: 547
python如何将内容转换为字符串?

str():此函数将所有内容转换为字符串。

# Python program showing

# a use of str() function

a = 1

print(type(a))

# converting integer

# into string

a = str(a)

print(type(a))

s =[1, 2, 3, 4, 5]

print(type(s))

# converting list

# into string

s = str(s)

print(type(s))

输出:

<class'int'>
<class'str'>
<class'list'>
<class'str'>
0.0000
6
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子