首页 > 代码库 > 【Python基础教程第2版】——第一讲:基础知识
【Python基础教程第2版】——第一讲:基础知识
1、长字符串:(用三引号如‘‘‘或者"""来引起来)
>>> print """
This is a very log string.
It continues here.
And it‘s not over yet.
"Hello world!"
"""
This is a very log string.
It continues here.
And it‘s not over yet.
"Hello world!"
2、原始字符串:(注:最后面不要出现转义符,其他的都会保持原样显示,中间不用使用转义符)
>>> print r‘C:\nowhere‘
C:\nowhere
3、字符串表示:str和repr
(str函数:会把值转换为合理形式的字符串;repr函数:会创建一个字符换,以合法的Python表达式的形式来表示值)
>>> print str(temp)
42
>>> print ‘1238934‘+str(temp)
123893442
>>> print ‘the temp is ‘+ repr(temp)
the temp is 42
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。