官术网_书友最值得收藏!

Console input

Doing interesting things with code usually requires some kind of input from a user. Input from the console can be obtained with the io.read() function. Unlike the functions used previously, nothing goes inside the parentheses of this one. The function will read one line of input from the user when the user presses Enter. The function returns this line of text as a string, which can be stored in a variable. The following example demonstrates this:

print ("Please enter your name:")
name = io.read()
print ("Hello " .. name)
主站蜘蛛池模板: 句容市| 成都市| 霍林郭勒市| 平远县| 厦门市| 大港区| 宜宾县| 隆安县| 文水县| 腾冲县| 望城县| 吉林省| 仁怀市| 新野县| 望奎县| 清新县| 马公市| 威远县| 县级市| 大宁县| 邵阳县| 安丘市| 勃利县| 遂宁市| 泽州县| 奉新县| 盐边县| 崇左市| 邵阳县| 荆门市| 洛隆县| 青海省| 高雄县| 承德市| 普兰县| 天水市| 万山特区| 梁河县| 都兰县| 隆回县| 富阳市|