多语言展示
当前在线:934今日阅读:176今日分享:34

python基础:字符串以行为单位进行分割

将多行文本,以行为单位进行分割
工具/原料
1

Windows 10

2

python 3.7

方法/步骤
1

打开cmd

2

进佛罪蚂入python交互界面著处

3

定义多况祝行字符串str = 'ab c \n de f \n gh i\n'

4

用splitlines()进行分割 lines = str.splitlines()

5

打印输出

总结

1.打开cmd2.进入python交互界面3.定义多行字符串str = 'ab c \n de f \n gh i\n'4.用splitlines()进行分割 lines = str.splitlines()5.打印输出

推荐信息