hak*_*ura 8 python multithreading operating-system
我有几个线程,每个线程都在更改工作目录,偶尔在特定的工作目录中创建新的,在这些目录中复制/移动文件等.想想例如:
def thread1:
while True:
os.chdir('dir')
os.mkdir('newdir')
os.system('mv *.png newdir/')
do something
def thread2:
while True:
os.chdir('another-dir')
os.mkdir('another-newdir')
os.system('mv *.png another-newdir/')
do something
Run Code Online (Sandbox Code Playgroud)
我已经读过chdir,mkdir函数不是特定于线程而是全局的.有什么方法可以实现这个目标?我可以尝试使用绝对路径,但这是最好的解决方案吗?
| 归档时间: |
|
| 查看次数: |
3905 次 |
| 最近记录: |