輸入
用print()
,括號(hào)中為輸出內(nèi)容喉刘,代碼實(shí)現(xiàn)如下:
>>>print('hello world')
hello world
>>>print('A','B','C')
A B C
>>>print('100+200='100+200)
100+200=300
輸出
用input()
瞧柔,可以輸入字符,并放在一個(gè)變量里睦裳,代碼實(shí)現(xiàn)如下:
>>>name=input()
Alice
>>>name
Alice
>>>print(name)
Alice
input()
括號(hào)中可以寫入提示信息造锅,代碼如下:
name=input('please enter your name:')
print('hello', name)
此時(shí)運(yùn)行結(jié)果會(huì)得到:
C:\Users\fr>python hello.py
Alice
hello Alice