我收到關於沒有這樣的文件或目錄爲我的Python代碼的錯誤消息。我將文件保存在我的臺式電腦上。但我收到錯誤消息Python:沒有這樣的文件或目錄
#!/usr/bin/python
fh=open("C:/Users/****/Desktop/IP Data","r")
for line in fh.readlines():
line = line.strip()
words = line.split()
# increase counters
for word in words:
if len(words)>3:
if "IP" in words[1]:
print '%s\t%s' % (words[2],1)
嘗試使其成爲原始字符串,如'r「C:/ Users/****/Desktop/IP Data」 – 2015-04-05 19:18:23
@BhargavRao,你是這樣說的:fh = open(「 r C:/用戶/ **** /桌面/ IP數據「,」r「) – user2803053 2015-04-05 19:22:23
@BhargavRao,我收到同樣的錯誤。我有我的程序在虛擬框中有Windows 7.我安裝python 2.7 – user2803053 2015-04-05 19:31:27