小编Iem*_*rog的帖子

我怎样才能转换os.path.getctime()

我怎样才能转换os.path.getctime() 到合适的时间?

我的源代码是:

import os

print("My Path: "+os.getcwd())
print(os.listdir("."))
print("Root/: ",os.listdir("/"))


for items in os.listdir("."):
    if os.path.isdir(items):
        print(items+" "+"Is a Directory")
        print("---Information:")
        print("    *Full Name: ",os.path.dirname(items))
        print("    *Created Time: ",os.path.getctime(items))
        print("    *Modified Time: ",os.path.getmtime(items))
        print("    *Size: ",os.path.getsize(items))
    else:
        print(items+" Is a File")
Run Code Online (Sandbox Code Playgroud)

输出:

---Information:
    *Full Name:  
    *Created Time:  1382189138.4196026
    *Modified Time:  1382378167.9465308
    *Size:  4096
Run Code Online (Sandbox Code Playgroud)

python os.path

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

了解变量类型,名称和赋值

在Python中,如果要定义变量,则不必指定其类型,这与其他语言(如C和Java)不同.

那么Python解释器如何区分变量并在内存中提供所需的空间,如intfloat

python

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

我如何在Python3.3中使用fork()

我如何在Python3.3中使用fork()这是我的代码:

输入:

#!/usr/bin/env python
import os

def Child_process():
    print("We are in Child_Process")
    print("My PID: %d"%os.getpid())
    print("Child_Process is exiting")

def Parent_process():
    print("-------Parent_process---------")
    wpid = os.fork()
    if wpid==0:
        print("wpid is 0 means We are in Child_process")
        print("Child :%d"%wpid)
        Child_process()
    else:
        print("Execute Parent_process")
        print("Parent_process %d"%wpid)
        Parent_process()

Parent_process()
Run Code Online (Sandbox Code Playgroud)

输出:

C:\Python33\python.exe C:/Users/Iem-Prog/Desktop/Py/Fork

Traceback (most recent call last):

  File "C:/Users/Iem-Prog/Desktop/Py/Fork", line 21, in <module>
-------Parent_process---------
    Parent_process()
  File "C:/Users/Iem-Prog/Desktop/Py/Fork", line 11, in Parent_process
    wpid = os.fork()

AttributeError: 'module' object has no attribute 'fork'
Run Code Online (Sandbox Code Playgroud)

python windows

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

标签 统计

python ×3

os.path ×1

windows ×1