S60 Python 编程指南——定义函数

来源:百度文库 编辑:神马文学网 时间:2024/04/29 11:43:15
练习: 定义一个函数
*以下的示例展示了如何定义一个函数:

说明:

示例代码:
# Copyright (c) 2005 Jurgen Scheible
# defining a function
import appuifw
def afunction():
data = appuifw.query(u"Type a word:", "text")
appuifw.note(u"The typed word was: " +data, "info")
afunction()
代码说明:
# Copyright (c) 2005 Jurgen Scheible
# defining a simple function
import appuifw
# a function is definded with: def nameoffunction():
# be aware of the indentation! (4 x spacebar)
def afunction():
data = appuifw.query(u"Type a word:", "text")
appuifw.note(u"The typed word was: " +data, "info")
# a function is called with its name and brackets behind it
afunction()