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函數

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379078.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379078.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379078.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

關于 MySQL 主從復制的配置(轉)

來源:http://www.oschina.net/bbs/thread/10388設置Mysql的主從設置很重要,有如下幾點用處:1 做備份機器,一旦主服務器崩潰,可以直接啟用從服務器作為主服務器2 可以直接鎖定從服務器的表只讀,然后做備份數…

Silverlight 同域WCF免跨域文件

在sl3使用wcf時常常會因為sl中調用了不同域的wcf服務而導至調用服務失敗,記得在很久以前sl當是只支持同域的訪問,那么讓我有一個想法,就是在sl引用時可以動態地取得當前sl所在的域,而wcf服務也必須同時部署到這個域下邊&#xff0…

使用ffmpeg 的 filter 給圖片添加水印

使用ffmpeg 的 filter 給圖片添加水印。 main.c #include <stdio.h>#include <libavfilter/avfilter.h> #include <libavfilter/buffersrc.h> #include <libavfilter/buffersink.h> #include <libavformat/avformat.h> #include <libavcodec…

程序崩潰 分析工具_程序分析工具| 軟件工程

程序崩潰 分析工具A program analysis tool implies an automatic tool that takes the source code or the executable code of a program as information and produces reports with respect to a few significant attributes of the program, for example, its size, multif…

28335接兩個spi設備_IIC和SPI如此流行,誰才是嵌入式工程師的必備工具?

IICvs SPI現今&#xff0c;在低端數字通信應用領域&#xff0c;我們隨處可見 IIC (Inter-Integrated Circuit) 和 SPI (Serial Peripheral Interface)的身影。原因是這兩種通信協議非常適合近距離低速芯片間通信。Philips(for IIC)和 Motorola(for SPI) 出于不同背景和市場需求…

線性表15|魔術師發牌問題和拉丁方陣 - 數據結構和算法20

線性表15 : 魔術師發牌問題和拉丁方陣 讓編程改變世界 Change the world by program 題外話 今天小甲魚看到到微博有朋友在問&#xff0c;這個《數據結構和算法》系列課程有木有JAVA版本的&#xff1f; 因為這個問題之前也有一些朋友問過&#xff0c;所以咱在這里統一說下哈…

[ZT]Three ways to tell if a .NET Assembly is Strongly Named (or has Strong Name)

Here are several convenient ways to tell whether a .NET assembly is strongly named. (English language note: I assume the form “strongly named” is preferred over “strong named” since that’s the form used in the output of the sn.exe tool shown immediat…

最佳頁面置換算法

在一個請求分頁系統中&#xff0c;采用最佳頁面置換算法時&#xff0c;假如一個作業的頁面走向為4、3、2、1、4、3、5、4、3、2、1、5&#xff0c;當分配給該作業的物理塊數M分別為3和4時&#xff0c;試計算在訪問過程中所發生的缺頁次數和缺頁率。請給出分析過程。 解析&…

網絡名稱 轉換 網絡地址_網絡地址轉換| 計算機網絡

網絡名稱 轉換 網絡地址At the time of classful addressing, the number of household users and small businesses that want to use the Internet kept increasing. In the beginning, a user was connected to the Internet with a dial-up line, for a specific period of…

rstudio 修改代碼間距_第一章 R和RStudio

R與RStudioR是一種統計學編程語言&#xff0c;在科學計算領域非常流行。它是由Ross Ihaka和Robert Gentleman開發的&#xff0c;是 "S "編程語言的開源實現。R也是使用這種語言進行統計計算的軟件的名字。它有一個龐大的在線支持社區和專門的軟件包&#xff0c;可以為…

ubuntu下最穩定的QQ

一、安裝好 Wine 1.2&#xff08;1.2 版安裝好就支持中文界面的了&#xff09; 當然得有WINE 了 當然我的有 如果沒有可以如下方法得到&#xff1a; 第一種方法&#xff1a;如果你已經安裝過 Wine 的老版本&#xff0c;那么只要添加 Wine 1.2 的軟件源&#xff0c;然后去新立得…

字體Times New Roman

Windows系統中的字體是Monotype公司為微軟公司制作的Times New Roman PS&#xff08;TrueType字體&#xff09;&#xff0c;視窗系統從3.1版本開始就一直附帶這個字體。而在蘋果電腦公司的麥金塔系統中使用的是Linotype公司的 Times Roman (在Macintosh系統中直接簡稱為‘Times…

最近最久未使用頁面置換算法

在一個請求分頁系統中&#xff0c;采用最近最久未使用頁面置換算法時&#xff0c;假如一個作業的頁面走向為4、3、2、1、4、3、5、4、3、2、1、5&#xff0c;當分配給該作業的物理塊數M分別為3和4時&#xff0c;試計算在訪問過程中所發生的缺頁次數和缺頁率。請給出分析過程。 …

ffplay的數據結構分析

《ffplay分析&#xff08;從啟動到讀取線程的操作&#xff09;》 《ffplay分析&#xff08;視頻解碼線程的操作&#xff09;》 《ffplay分析&#xff08;音頻解碼線程的操作&#xff09;》 《ffplay 分析&#xff08;音頻從Frame(解碼后)隊列取數據到SDL輸出&#xff09;》 《f…

tolowercase_Java String toLowerCase()方法與示例

tolowercase字符串toLowerCase()方法 (String toLowerCase() Method) toLowerCase() method is a String class method, it is used to convert given string into the lowercase. toLowerCase()方法是String類方法&#xff0c;用于將給定的字符串轉換為小寫。 Syntax: 句法&a…

python web 服務器實時監控 websocket_python websocket網頁實時顯示遠程服務器日志信息...

功能&#xff1a;用websocket技術&#xff0c;在運維工具的瀏覽器上實時顯示遠程服務器上的日志信息一般我們在運維工具部署環境的時候&#xff0c;需要實時展現部署過程中的信息&#xff0c;或者在瀏覽器中實時顯示程序日志給開發人員看。你還在用ajax每隔段時間去獲取服務器日…

磁盤調度算法

1&#xff0c;假設磁頭當前位于第105道&#xff0c;正在向磁道序號增加的方向移動&#xff0c;現有一個磁道訪問請求序列為&#xff1a;35&#xff0c;45&#xff0c;12&#xff0c;68&#xff0c;100&#xff0c;180&#xff0c;170&#xff0c;195&#xff0c;試用先來先服務…

C# Using用法三則

&#xff08;1&#xff09;引用命名空間 using作為引入命名空間指令的用法準則為&#xff1a; using Namespace; 在.NET程序中&#xff0c;最多見的代碼莫過于在程序文件的開頭引入System命名空間&#xff0c;其原由在于System命名空間中封裝了許多最基本最常用的操作&#xff…