我是初学者,在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) 我想允许用户根据他们的字符串输入参数导入一个模块。
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) 我试图使用telnetlib库在python中发送control + c命令.目前我在做
tn.write('^]')
Run Code Online (Sandbox Code Playgroud)
但上面的代码似乎不起作用.关于我应该使用什么的任何线索?
有时我见过人们_.在python代码中使用表达式.例如,
_.objectName = 23
Run Code Online (Sandbox Code Playgroud)
有人可以帮我确切地说"_".意思?有人可以给我更多这种类型的例子并附上解释吗?
我想知道如何执行线性逼近并从python中的数据数组中获取线性方程.
即它会是这样的
linapprox((0,0),(1,1),(2,1.9),(3,3.1))
> y = x
Run Code Online (Sandbox Code Playgroud)