python " />

扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

python瀛楃涓插崰浣嶇鏇挎崲鎬庝箞瀹炵幇

扬州沐宇科技
2023-10-17 04:40:25
python

鍦≒ython涓紝鍙互浣跨敤涓ょ鏂规硶鏉ュ疄鐜板瓧绗︿覆鍗犱綅绗︾殑鏇挎崲銆?/p>

鏂规硶涓€锛氫娇鐢ㄧ櫨鍒嗗彿鍗犱綅绗?/p>

name = "John"
age = 25
print("My name is %s and I am %d years old." % (name, age))

杈撳嚭缁撴灉锛歁y name is John and I am 25 years old.

鍦ㄤ笂闈㈢殑绀轰緥涓紝%s琛ㄧず瀛楃涓插崰浣嶇锛?d琛ㄧず鏁存暟鍗犱綅绗︺€備娇鐢?鍚庨潰鐨勬嫭鍙蜂紶鍏ュ彉閲忓€艰繘琛屾浛鎹€?/p>

鏂规硶浜岋細浣跨敤format()鏂规硶

name = "John"
age = 25
print("My name is {} and I am {} years old.".format(name, age))

杈撳嚭缁撴灉锛歁y name is John and I am 25 years old.

鍦ㄤ笂闈㈢殑绀轰緥涓紝{}琛ㄧず鍗犱綅绗︼紝浣跨敤format()鏂规硶浼犲叆鍙橀噺鍊艰繘琛屾浛鎹€?/p>

杩欎袱绉嶆柟娉曢兘鍙互鐢ㄤ簬鏇挎崲瀛楃涓蹭腑鐨勫崰浣嶇锛屼綘鍙互鏍规嵁鑷繁鐨勫枩濂介€夋嫨鍏朵腑涓€绉嶄娇鐢ㄣ€?/p>

扫码添加客服微信