社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Anurag A S

Anurag A S 最近创建的主题
Anurag A S 最近回复了
6 年前
回复了 Anurag A S 创建的主题 » 如何将输入作为参数传递给python中的另一个函数?它不

程序中的executecommand函数接受输入mydoc并打印输入。
当程序运行时,它正是这样做的。以下给定示例中的输入hello被视为函数executecommand的输入。此函数打印 hello 并返回到调用程序main,然后由于没有更多语句而终止。

>>> def executeCommand(myDoc): 
...     print(myDoc)
...     return 
... 
>>> def insert():
...     print("insert command:")
...     return
... 
>>> def delete():
...     print("delete command:")
...     return
... 
>>> def main():
...     print("Functional Text Editor ")
...     executeCommand(input("Type in file name: "))
... 
>>> if __name__ == '__main__':
...     main()
... 
Functional Text Editor 
Type in file name: hello
hello
>>>