Python 使用字符串,python使用字符串,如下代码演示Python
Python 使用字符串,python使用字符串,如下代码演示Python
如下代码演示Python如何使用字符串
#!/usr/bin/python# 用单引号表示字符串,字符串内的单引号要做转义s1 = 'I\'m single'# python中也可以用双引号表示字符串s2 = "I'm double double"# python可以用三个单引号或者双引号包括多行文本的字符串s3 = '''I'm very long-winded and I really needto take up more than one line. That way I can say all the very`important' things which I must tell you. Strings like me are usefulwhen you must print a long set of instructions, etc.'''# 字符串之间用空格分隔s4 = 'left' "right" 'left'# 用加号做字符串相加操作s5 = s1 + "\n" + s2print s5 + '\n' + s3, "\n", s4print 's5 has', len(s5), 'characters'
相关内容
- python String (二),pythonstring,#!/usr/bin/p
- 用Python读写XML文件,Python读写XML文件,以前用Python中的
- python String (三) 字符串运算,pythonstring,#!/usr/bin/p
- python使用py2exe打包PyQt程序要点,py2exepyqt,使用png格式作
- python使用HTMLParser解析html,pythonhtmlparser,一个Python HTM
- Python list使用示例,pythonlist示例,#!/usr/bin/p
- python if 语句,pythonif,#!/usr/bin/p
- python while语句,pythonwhile,python while
- Python使用cx_Oracle将oracle数据表中的数据导出成csv,cx_
- python正则re模块学习笔记,pythonre学习笔记,python正则r
评论关闭