变量
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #author:wq 2016-4-12 print('n =',123) print('f =',456.789) print('s1 =',r"'Hello,world'") print("s2 = \'Hello,\\'Adam\\''") print("s3 = r\'Hello,\"Bart\"'") print("s4 = r\'''Hello,\nLisa!'''")
# python variable.py n = 123 f = 456.789 s1 = 'Hello,world' s2 = 'Hello,\'Adam\'' s3 = r'Hello,"Bart"' s4 = r'''Hello, Lisa!'''
说明:
r是为了打印原始字符串,屏蔽转义;
打印出来的原始字符串不能以\结尾,否者python不知道是否该以\结尾,除非你是为了输出\。