小编Dhr*_*tel的帖子

如何等待生成的线程在python中完成?

我是初学者,在python中使用线程.我需要一些帮助,我应该怎么做: - 产生一个线程 - 做一些有用的工作 - 等到线程完成 - 做一些有用的工作

我不太确定我是否安全地产生了一个线程.也可能需要一些帮助.

import threading

def my_thread(self):
    # Wait for the server to respond..


def main():
    a = threading.thread(target=my_thread)
    a.start()
    # Do other stuff here
Run Code Online (Sandbox Code Playgroud)

python multithreading thread-safety

3
推荐指数
1
解决办法
8389
查看次数

在python中,如何通过用户输入的模块名称字符串导入模块

我想允许用户根据他们的字符串输入参数导入一个模块。

IE

$python myprogram.py --import_option xyz.py
Run Code Online (Sandbox Code Playgroud)

在python中,我在解析一个参数后想要这样的东西。

arg = 'xyz.py'

import arg #assuming that the module name xyz.py exists.
Run Code Online (Sandbox Code Playgroud)

python string import arguments

3
推荐指数
1
解决办法
4524
查看次数

如何在python中发送telnetlib control + c命令

我试图使用telnetlib库在python中发送control + c命令.目前我在做

tn.write('^]')
Run Code Online (Sandbox Code Playgroud)

但上面的代码似乎不起作用.关于我应该使用什么的任何线索?

python telnet telnetlib

2
推荐指数
2
解决办法
6687
查看次数

什么时候 "_." 用于python

有时我见过人们_.在python代码中使用表达式.例如,

_.objectName = 23
Run Code Online (Sandbox Code Playgroud)

有人可以帮我确切地说"_".意思?有人可以给我更多这种类型的例子并附上解释吗?

python

1
推荐指数
1
解决办法
164
查看次数

如何执行线性逼近并从python中的数据数组中获取线性方程

我想知道如何执行线性逼近并从python中的数据数组中获取线性方程.

即它会是这样的

linapprox((0,0),(1,1),(2,1.9),(3,3.1))
> y = x
Run Code Online (Sandbox Code Playgroud)

python numpy matplotlib scipy pandas

0
推荐指数
1
解决办法
4884
查看次数