全稱為Separate意為分開隔開
用於print兩個元素時自訂間隔符(預設為兩個空格)
關鍵字參數sep是實作分隔符,例如多個參數輸出時想要輸出中間的分隔字元
print(1, 2, 3, sep = ',', end = '\r\n') print(1, 2, 3, sep = ' ', end = '\r\n')
相關推薦:《python影片教學》
結果輸出如下:
1,2,3 1 2 3
print("file\n","abc","bcd","fff\n","poi") print("-------------") print("file\n","abc","bcd","fff\n","poi",sep='') print("-------------") print("file\n","abc","bcd","fff\n","poi",sep=' ') print("-------------")
其結果為:
file abc bcd fff poi-------------file abcbcdfff poi-------------file abc bcd fff poi-------------
以上是python中sep是什麼意思的詳細內容。更多資訊請關注PHP中文網其他相關文章!