码迷,mamicode.com
首页 > 编程语言 > 详细

python数字转换为字符串的两种方式

时间:2017-08-06 00:17:44      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:log   nbsp   pre   div   hello   字符串   方式   style   class   

主要包括两种形式进行转换:
第一种是str(),将值转换为用户便于阅读的形式;
另一种是repr(),将值转换为合法的python表达式。
>>> print repr("Hello, world!")
Hello, world!
>>> print repr(10000L)
10000L
>>> print str("Hello, world!")
Hello, world!
>>> print str(10000L)
10000

 

python数字转换为字符串的两种方式

标签:log   nbsp   pre   div   hello   字符串   方式   style   class   

原文地址:http://www.cnblogs.com/stuqx/p/7291920.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!