日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python sep函数_Python中带有print()函数的sep参数

發布時間:2023/12/1 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python sep函数_Python中带有print()函数的sep参数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python sep函數

sep parameter stands for separator, it uses with the print() function to specify the separator between the arguments.

sep參數代表分隔符,它與print()函數一起使用以指定參數之間的分隔符。

The default value is space i.e. if we don't use sep parameter – then the value of the arguments is separated by the space. With the "sep", we can use any character, an integer or a string.

默認值為空格,即,如果我們不使用sep參數 ,則參數的值由空格分隔。 使用“ sep” ,我們可以使用任何字符,整數或字符串。

Note: "sep" is available in Python 3.x or later versions.

注意: “ sep”在Python 3.x或更高版本中可用。

Syntax:

句法:

print(argument1, argument2, ..., sep = value)

在print()中帶有'sep'參數的Python示例 (Python examples with 'sep' parameter in print())

Example 1:

范例1:

# variables name = "Mike" age = 21 city = "Washington, D.C."# printing without using sep parameter print("Without using sep parameter...") print(name, age, city) print()# printing with using sep parameter # separated by spaces print("With using sep parameter (separated by spaces)") print(name, age, city, sep=' ') print()# printing with using sep parameter # separated by colon (:) print("With using sep parameter (separated by colon)") print(name, age, city, sep=':') print()# printing with using sep parameter # separated by " -> " print("With using sep parameter (separated by ' -> ')") print(name, age, city, sep=' -> ') print()

Output:

輸出:

Without using sep parameter... Mike 21 Washington, D.C.With using sep parameter (separated by spaces) Mike 21 Washington, D.C.With using sep parameter (separated by colon) Mike:21:Washington, D.C.With using sep parameter (separated by ' -> ') Mike -> 21 -> Washington, D.C.

Example 2:

范例2:

# variables name = "Mike" age = 21 city = "Washington, D.C."# printing with using sep parameter # disable space separator print("With using sep parameter (disable space separator)") print(name, age, city, sep='') print()# printing with using sep parameter # separated by number print("With using sep parameter (separated by number)") print(name, age, city, sep='12345') print()# printing with using sep parameter # separated by " ### " print("With using sep parameter (separated by ' ### ')") print(name, age, city, sep=' ### ') print()

Output:

輸出:

With using sep parameter (disable space separator) Mike21Washington, D.C.With using sep parameter (separated by number) Mike123452112345Washington, D.C.With using sep parameter (separated by ' ### ') Mike ### 21 ### Washington, D.C.

翻譯自: https://www.includehelp.com/python/sep-parameter-in-python-with-print-function.aspx

python sep函數

總結

以上是生活随笔為你收集整理的python sep函数_Python中带有print()函数的sep参数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。