1、print函数
# 字符串另存文件 fp=open("d:/test.txt","a+") print("helloworld",file=fp) fp.close()
2、转义字符
# \n表示换行 print("hello\nworld") #\t 四个空格 print("hello\tworld") #\r 覆盖 print("hello\rworld") #\b 退回 print("hello\bworld") # \" 保留引号 print("老师说\"dajiahao\"")
3、原字符:不让转义字符起作用,在最前面加r
注意事项:最后一个字符不能是反斜杠\
print(r"hello\nworld")
|
|
来自: python_lover > 《待分类》