python - 快速检测本地网络路径
问题描述
Python有没有办法快速检测本地网络路径的存在?
我试过使用os.path.exists
and urllib2.urlopen
。当路径不存在时,它们至少需要几十秒的时间来检测路径是否存在。
有没有可能把时间缩短到十秒以内?
这是我的测试代码:
# -*- coding: utf-8 -*-
import os
import sys
from urllib2 import urlopen
path = "file:////192.168.199.249/Users"
try:
urlopen(path, timeout=1)
print "exist"
except Exception, e:
print "not exist"
if os.path.exists(path):
print "exist"
else:
print "not exist"
解决方案
推荐阅读
- asp.net - 在 mac 上的 azure data studio 上部署和传输数据库到服务器
- curl - HTTPS:Curl 因 getaddrinfo 错误而失败
- angular - 自定义 Angular 类型不可分配给类型 NgIterable
- python - 连接和排序后如何显示初始数组
- php - 多表编码json并显示
- php - 从 CSV 导入 ACF 中继器字段值
- excel - 在powershell中将变量添加到Select-Object命令并输出到excel csv
- javascript - JS IF Else And 语法
- jq - 从对象数组中提取嵌套属性
- java - ANDROID STUDIO - 设备断开电源时服务不工作