python基礎第一天之輸出
阿新 • • 發佈:2019-01-04
python與c++的第一個hello world程式區別在於,c++直接用‘ cout<< ’或者printf(" 字串%s ",字串變數名)進行輸出,而python則是用print(" 字串 ",字串變數名)進行輸出。 c++示例如下: ``` #include <iostream> using namespace std; #include "string" //當使用cout輸出字元時需要包含string庫 void main() { string name = "gentleman"; //--------cout法------ cout << "name is:%s\n" << name << endl; //--------printf法---- printf("name is:%s\n", name); }
python示例如下:
```
print("hello world")
name = "gentleman" #python中不需要定義變數型別,因為python是動態解釋語言,
print("name is :", name)
```