python学习——字符串

本章内容较为凌乱,要用到的时候再查询

 

 

字符串是最常用的数据类型,下面是几条例句:

1 #\n是换行
2 >>> s = "Here is a line \n split in two lines"
3 >>> s
4 'Here is a line \n split in two lines'
5 >>> print(s)
6 Here is a line
7  split in two lines

若想要自动包含代码中的换行符,使用'''或者"""

1 >>> print("""\
2 ... Usage: thingy [OPTIONS]
3 ...      -h                        Display this usage message
4 ...      -H hostname               Hostname to connect to
5 ... """)
6 Usage: thingy [OPTIONS]
7      -h                        Display this usage message
8      -H hostname               Hostname to connect to

 

posted @ 2022-01-07 20:01  一起开会  阅读(21)  评论(0)    收藏  举报