相关疑难解决方法(0)

如何卸载(重新加载)Python模块?

我有一个长期运行的Python服务器,并希望能够在不重新启动服务器的情况下升级服务.这样做的最佳方法是什么?

if foo.py has changed:
    unimport foo  <-- How do I do this?
    import foo
    myfoo = foo.Foo()
Run Code Online (Sandbox Code Playgroud)

python module reload python-import

759
推荐指数
15
解决办法
59万
查看次数

将Python脚本导入另一个?

我正在通过Zed Shaw的学习Python艰难的方式,我在第26课.在本课中,我们必须修复一些代码,代码从另一个脚本调用函数.他说我们不必导入它们来通过测试,但我很好奇我们将如何做到这一点.

链接到课程 | 链接到要更正的代码

以下是调用前一个脚本的特定代码行:

words = ex25.break_words(sentence)
sorted_words = ex25.sort_words(words)

print_first_word(words)
print_last_word(words)
print_first_word(sorted_words)
print_last_word(sorted_words)
sorted_words = ex25.sort_sentence(sentence)
print sorted_words
print_first_and_last(sentence)
print_first_a_last_sorted(sentence)
Run Code Online (Sandbox Code Playgroud)

python import python-2.7

53
推荐指数
3
解决办法
15万
查看次数

标签 统计

python ×2

import ×1

module ×1

python-2.7 ×1

python-import ×1

reload ×1