练习: 定义一个函数
*以下的示例展示了如何定义一个函数:

说明:
 示例代码: # 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()
|