我有以下片段:#!/usr/bin/env pythonimport sysmypath = "D:\inetpub\wwwroot"if mypath: try: print "Path: %s" % mypath if mypath.find("/"): print "OS: Linux/Unix" elif mypath.find(":"): print "OS: Windows" else: print "OS: Unknown" except: print "Error"else: print "[?] OS detection failure."执行输出:$ python test.pyPath: D:\inetpub\wwwrootOS: Linux/Unix我究竟做错了什么?我得到与预期相反的结果。还是有更好的方法来做到这一点?“ /”-> Linux / Unix和“:”-> Windows
添加回答
举报
0/150
提交
取消