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 > 《待分類》