小编Int*_*...的帖子

如何在Python中获取父目录的名称?

我在python中有一个程序打印出有关文件系统的信息......我需要知道将父目录的名称保存到变量中...

例如,如果文件系统的一小部分看起来像这样:
ParentDirectory
ChildDirectory
SubDirectory
如果我在ChildDirectory中,我需要将名称ParentDirectory保存到某个字符串...这里有一些伪代码:
import os
var = os.path.parent()
print var
在旁注,我使用的是Python 2.7.6,所以我需要兼容2.7.6 ......

python directory variables

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

如何在Python中实现守护进程?

我正在编写一个小程序,它有一个心跳过程和一个回声过程.我用多处理库实现了这个,但它似乎不起作用.

from multiprocessing import Process
import os
import time

def ticking():
    while True:
        time.sleep(1)
        print 'ticking'

def echo():
    while True:
        a = raw_input('please type something')
        print 'echo: ' + a

if __name__ == '__main__':
    p = Process(target=ticking, args=())
    p.start()
    p.join()

    p = Process(target=echo, args=())
    p.start()
    p.join()
Run Code Online (Sandbox Code Playgroud)

python daemon multiprocessing

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

标签 统计

python ×2

daemon ×1

directory ×1

multiprocessing ×1

variables ×1