python 定义文本
The task to create a user-defined method and we have to pass a text/string that should be printed on the screen.
创建用户定义方法的任务,我们必须传递应该在屏幕上打印的文本/字符串。
In the below program, we are defining a method named putMe() it will accepts a string/text and print it on the screen using print() python.
在下面的程序中,我们定义了一个名为putMe()的方法,它将接受字符串/文本,并使用print() python在屏幕上打印该方法。
使用用户定义的方法打印文本/字符串的Python代码 (Python code to print text/string using user-defined method)
# Python code to print text/string using
# user-defined method
# function defintion of "putMe()"
# it will accepts a string and print it on the screen
def putMe(text):
# printing text on the screen
print(text)
# main code
if __name__ == '__main__':
putMe('Hello world!')
putMe('Welcome @')
putMe('IncludeHelp')
putMe('The world of programming')
putMe('A programming community for developer and students')
Output
输出量
Hello world!
Welcome @
IncludeHelp
The world of programming
A programming community for developer and students
翻译自: https://www.includehelp.com/python/print-given-text-using-a-user-defined-method.aspx
python 定义文本