1. 程式人生 > >Python基礎(一)輸入與輸出

Python基礎(一)輸入與輸出

前言:之前使用的java,現在使用java和python對比的方式學習python

1. 輸出: print()

java中列印輸出

System.out.print(引數)

python比java簡單,直接print(引數1,引數2,引數3)

print('hello word')
##print輸入多個字元,逗號隔開
print('this is a dog','yes','so cute')

##print列印int值

print(200)

##print 計算

print('100+200=',100+200)

輸出結果
在這裡插入圖片描述

2,輸入

###輸入,input():等待使用者輸入

name = input()

###按照提示輸入口敲回車,就把我們輸入的值儲存到name變數中了,那麼name是什麼資料型別呢,答案是未知
###因為python不需要宣告變數型別,會自動根據賦值的資料去匹配型別,除非是自定義的實體類,需要宣告


print('hello',name)


###input()增加提示語引數

name = input('please input your name')

print('hello',name)

執行結果
在這裡插入圖片描述