一层引号形式
输入:"hello"
输出:'hello'
输入:'hello'
输出:'hello'
输入:"""hello"""
输出:'hello'
输入:'''hello'''
输出:'hello'
二层引号形式
注意python对引号的处理,双引号里面只有单引号,则不变,有双引号则变为单引号
输入:"hello,'world'" 或"hello,\'world\'"
输出:"hello,'world'"
输入:"hello,\"world\""
输出:'hello,"world"'
#外层有引号内部的引号可以不是双数
输入:"hello,a'b\'c'd"
输出:"hello,a'b'c'd"
输入:"hello,a'b'c\'f\'d"
输出:"hello,a'b'c'f'd"
#都是双引号,最外层会转换层单引号
输入:"hello,\"world\""
输出:'hello,"world"'
输入:"hello\',\"world\""或"hello',\"world\""
输出:'hello\',"world"'
输入:'hello\' ,"world"'
输出:'hello\' ,"world"'
输入:"""hello',world\""""
输出:'hello\',world"'
三层引号
三引号并不需要对称
输入:"""\"'word\'"""""""""
输出:'"\'word\''
#不用三引号,会出现引号输出降层
输入:'"hello,\"word\""'
输出: '"hello,"word""'
三层引号比较复杂,最好内部两层引号使用不同的引号,如单引号和双引号,不用转义的引号区分层
1万+

被折叠的 条评论
为什么被折叠?



