在程式設計中,時常會要求使用者輸入資料,在 python 使用 input 函數可以達到這功能,語法如下:
變數 = input("提示字串")
說明:回傳的變數值為字串資料型態
範例:
- # -*- coding: utf-8 -*-
- """
- Created on Sun Jan 20 22:37:14 2019
- @author: 軟體罐頭
- """
- score = input("請輸入程式設計成績:")
- print("這次程式設計成績:", score ,"分")
- print("score的資料型態為:", type(score))
執行結果:

