【问题标题】:Python calling functions in terminal after modifying it修改后在终端中调用Python函数
【发布时间】:2016-10-12 08:23:36
【问题描述】:

我正在使用终端测试我在文件中编写的函数。我的系统是 Ubuntu 16.04 和 Python 2.7。我发现每次更改函数的内容后,我都会从终端再次执行,似乎没有应用更改。

我的实际目标是为 Tensorflow 计算设计函数和类,但现在,它应该只是关于 Python 的问题。

我的意思是,首先在终端进入python环境并导入文件,比如说import try_function as trf,然后调用trf.try1() #suppose it prints 'hello world'。在我更改try1() 使其打印'hello' 后,从终端trf.try1() 运行它,它仍然打印'hello world',即使我再次尝试import try_function as trf,它仍然无法正常工作。有人能告诉我如何让终端执行最新版本的代码吗?谢谢。

【问题讨论】:

标签: python-2.7 tensorflow ubuntu-16.04


【解决方案1】:

您可能应该使用reload

另见this related question

【讨论】:

  • 谢谢你的帮助,我只需要reload(trf)
猜你喜欢
  • 2017-11-25
  • 2023-02-08
  • 2020-01-22
  • 2011-10-20
  • 2015-03-16
  • 2020-04-16
  • 1970-01-01
  • 1970-01-01
  • 2021-08-27
相关资源
最近更新 更多