C++:
printf
python :
name = "keivin"
print("testname%s, hello"% name)
兩者的名字不一樣,c++多一個f
C++:
#include<stdio.h>
main()
{
char* name ="keivin";
printf("testname %s hello",name);
}
我們看到python中print("testname%s, hello"% name)
python中需要使用 %加變數名
而C++語言中printf("testname %s hello",name);
C++中是直接用逗號分隔變數的,
python中多個格式化輸出要用元組 多個變數要用括號括起來 的形式
a = 6.5
b = 7.2
c = 100
print("a=%.2f,b=%.2f ,c=%.2d"%(a,b,c))
c++
float a = 6.5;
float b = 7.2;
int c = 100;
printf("a=%.2f,b=%.2f ,c=%.2d",a,b,c);
先寫到這里吧,等我更熟悉了再來更新,我也是個水鳥
CSDN認證博客專家
C/C++
vc/qt
音視頻
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/262934.html
標籤:python
