python续行符\ &'''........'''

续行符后面不能跟空格:

[python]  view plain  copy
  1. print'a'\  
  2.       'b')  
输出结果:

[html]  view plain  copy
  1. ab  

[python]  view plain  copy
  1. print'a'\   
  2.       'b')  
输出结果:

[html]  view plain  copy
  1. File "C:/Users/Administrator/untitled2.py", line 8  
  2.    print( 'a'\  
  3.                ^  
  4. yntaxError: unexpected character after line continuation character  

总之,写了续行符之后,续行符后面什么都不能 出现,必须换行(必须换行写内容):


[python]  view plain  copy
  1. print'a'\'c'  
  2.       'b')  
输出结果:

[html]  view plain  copy
  1. File "C:/Users/Administrator/untitled2.py", line 8  
  2.    print( 'a'\'c'  
  3.                  ^  
  4. yntaxError: unexpected character after line continuation character  

[python]  view plain  copy
  1. print'a'\\  
  2.       'b')  


输出结果:

[html]  view plain  copy
  1. File "C:/Users/Administrator/untitled2.py", line 8  
  2.    print( 'a'\\  
  3.                ^  
  4. yntaxError: unexpected character after line continuation character  


[python]  view plain  copy
  1. print'a'\)  

输出结果:

[html]  view plain  copy
  1. File "C:/Users/Administrator/untitled2.py", line 8  
  2.    print( 'a'\)  
  3.                ^  
  4. yntaxError: unexpected character after line continuation character  

[python]  view plain  copy
  1. print'a'\  
  2.       )  


输出结果:


[html]  view plain  copy
  1. a  



猜你喜欢

转载自blog.csdn.net/weixin_41071202/article/details/80218036