【发布时间】:2011-06-10 18:47:09
【问题描述】:
python 可以检测操作系统,然后为文件系统构造 if/else 语句。
我需要将 Fn 字符串中的 C:\CobaltRCX\ 替换为 FileSys 字符串。
import os.path, csv
from time import strftime
if os.path.?????:## Windows
FileSys = r"C:\\working\\"
else: ##linux
FileSys = r"\\working\\"
y=(strftime("%y%m%d"))
Fn = (r"C:\\working\\Setup%s.csv" %y)
【问题讨论】:
-
platform.system() == platform.uname()[0] == 'Windows'