python中系统找不到指定文件怎么办,Python“系统找不到指定的文件”
我正在尝试编写一个OpenDyslexic字体的安装程序。我已经在https://github.com/kirbyfan64/OpenDyslexic-Installer上有一个Linux版本,但是Windows版本(显然)目前还不太好用。这是UAC问题吗?我想不出别的办法了。有两个奇怪的部分:程序正在通过else子句和filecmp找到了第一个文件。我有一种感觉,执行else是因为与filecmp问题相同的问题。在
代码:"""This work is licensed under the
Creative Commons Attribution-
NonCommercial-ShareAlike 3.0 Unported
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/3.0/
or send a letter to Creative Commons,
444 Castro Street, Suite 900, Mountain View,
California, 94041, USA."""
import urllib
import os
import os.path
import shutil
import filecmp
import sys
def fcheck(filename):
try:
with open(filename) as f:
return True
except IOError:
return False
homedir = os.environ['SystemRoot']
tempdir = os.environ['TEMP']
fontsdir = homedir + r'\Fonts'
installcheck = fontsdir + r'\OpenDyslexic-Regular.otf'
dpath = tempdir + r'\OpenDyslexic-Regular.otf'
dpath2 = tempdir + r'\OpenDyslexic-Bold.otf'
dpath3 = tempdir + r'\OpenDyslexic-Italic.otf'
dpath4 = tempdir + r'\OpenDyslexic-BoldItalic.otf'
print 'OpenDyslexic Installer Beta 1'
print ''
raw_input ('Press enter to install OpenDyslexic')
urllib.urlretrieve ('https://github.com/antijingoist/open-dyslexic/raw/master/otf/OpenDyslexic-Regular.otf', dpath)
urllib.urlretrieve ('https://github.com/antijingoist/open-dyslexic/raw/master/otf/OpenDyslexic-Bold.otf', dpath2)
urllib.urlretrieve ('https://github.com/antijingoist/open-dyslexic/raw/master/otf/OpenDyslexic-Italic.otf', dpath3)
urllib.urlretrieve ('https://github.com/antijingoist/open-dyslexic/raw/master/otf/OpenDyslexic-BoldItalic.otf', dpath4)
ifinstall = fcheck(installcheck)
if ifinstall == True:
updcheck = 0
originstall = fontsdir + r'\OpenDyslexic-Regular.otf'
originstall2 = fontsdir + r'\OpenDyslexic-Bold.otf'
originstall3 = fontsdir + r'\OpenDyslexic-Italic.otf'
originstall4 = fontsdir + r'\OpenDyslexic-BoldItalic.otf'
newupdate = filecmp.cmp(dpath, originstall)
newupdate2 = filecmp.cmp(dpath2, originstall2)
newupdate3 = filecmp.cmp(dpath3, originstall3)
newupdate4 = filecmp.cmp(dpath4, originstall4)
if newupdate == False:
updcheck = updcheck + 1
if newupdate2 == False:
updcheck = updcheck + 1
if newupdate3 == False:
updcheck = updcheck + 1
if newupdate4 == False:
updcheck = updcheck + 1
if updcheck != 0:
raw_input ('Update Avalible. Press Enter to install.')
os.remove(originstall)
os.remove(originstall2)
os.remove(originstall3)
os.remove(originstall4)
shutil.copyfile(dpath, originstall)
shutil.copyfile(dpath2, originstall2)
shutil.copyfile(dpath3, originstall3)
shutil.copyfile(dpath4, originstall4)
tst1 = fcheck(originstall)
tst2 = fcheck(originstall2)
tst3 = fcheck(originstall3)
tst4 = fcheck(originstall4)
tst5 = 0
if tst1 == False:
tst5 = tst5 + 1
if tst2 == False:
tst5 = tst5 + 1
if tst3 == False:
tst5 = tst5 + 1
if tst4 == False:
tst5 = tst5 + 1
if tst5 != 0:
if tst1 == True:
os.remove(originstall)
if tst2 == True:
os.remove(originstall2)
if tst3 == True:
os.remove(originstall3)
if tst4 == True:
os.remove(originstall4)
raw_input ('Installation Unsuccesful. Press Enter to exit.')
sys.exit()
os.remove(dpath)
os.remove(dpath2)
os.remove(dpath3)
os.remove(dpath4)
raw_input ('Installation Succesful. Press Enter to exit.')
sys.exit()
else:
os.remove(dpath)
os.remove(dpath2)
os.remove(dpath3)
os.remove(dpath4)
raw_input ('No Update Avalible. Press Enter to exit.')
sys.exit()
else:
originstall = homedir + r'\Fonts\OpenDyslexic-Regular.otf'
originstall2 = homedir + r'\Fonts\OpenDyslexic-Bold.otf'
originstall3 = homedir + r'\Fonts\OpenDyslexic-Italic.otf'
originstall4 = homedir + r'\Fonts\OpenDyslexic-BoldItalic.otf'
newupdate = filecmp.cmp(dpath, originstall)
newupdate2 = filecmp.cmp(dpath2, originstall2)
newupdate3 = filecmp.cmp(dpath3, originstall3)
newupdate4 = filecmp.cmp(dpath4, originstall4)
shutil.copyfile(dpath, originstall)
shutil.copyfile(dpath2, originstall2)
shutil.copyfile(dpath3, originstall3)
shutil.copyfile(dpath4, originstall4)
tst1 = fcheck(originstall)
tst2 = fcheck(originstall2)
tst3 = fcheck(originstall3)
tst4 = fcheck(originstall4)
tst5 = 0
if tst1 == False:
tst5 = tst5 + 1
if tst2 == False:
tst5 = tst5 + 1
if tst3 == False:
tst5 = tst5 + 1
if tst4 == False:
tst5 = tst5 + 1
if tst5 != 0:
if tst1 == True:
os.remove(originstall)
if tst2 == True:
os.remove(originstall2)
if tst3 == True:
os.remove(originstall3)
if tst4 == True:
os.remove(originstall4)
raw_input ('Installation Unsuccesful. Press Enter to exit.')
sys.exit()
os.remove(dpath)
os.remove(dpath2)
os.remove(dpath3)
os.remove(dpath4)
raw_input ('Installation Succesful. Press Enter to exit.')
sys.exit()
错误:
^{pr2}$
python中系统找不到指定文件怎么办,Python“系统找不到指定的文件”相关推荐
- Python中的psutil:一个用于获得处理器和系统相关信息的模块
http://www.crifan.com/try_python_psutil/ 无意间得知了psutil模块,去网上找了下,找到: http://pypi.python.org/pypi/psuti ...
- Python中的图像处理(第六章)Python图像量化及采样处理(2)
Python中的图像处理(第六章)Python图像量化及采样处理(2) 前言 一. Python准备 二. Python仿真 三. 小结 前言 随着人工智能研究的不断兴起,Python的应用也在不断上 ...
- Python中的图像处理(第十一章)Python图像锐化及边缘检测(1)
Python中的图像处理(第十一章)Python图像锐化及边缘检测(1) 前言 一. Python准备 二. Python仿真 三. 小结 前言 随着人工智能研究的不断兴起,Python的应用也在不断 ...
- Python中通过索引名称提取数据loc()函数Python中通过行和列下标提取数据iloc()函数
[小白从小学Python.C.Java] [Python全国计算机等级考试] [Python数据分析考试必会题] ● 标题与摘要 Python中通过索引名称提取数据 loc()函数 Python中通过 ...
- python中导入模块使用哪个关键字_关于python导入模块的关键字介绍
关于python导入模块的关键字介绍 发布时间:2020-04-17 10:13:26 来源:亿速云 阅读:101 作者:小新 今天小编给大家分享的是关于python导入模块的关键字介绍,很多人都不太 ...
- python下列合法的变量名是什么,python中的合法变量名有什么规则-Python教程
python中非法变量名的规定有:一.能够由字母.数字.下划线组成,同时,不克不及以数字扫尾:二.不克不及是python要害字,但能够蕴含要害字:三.不克不及蕴含空格.例如:[a1c_x2z]. Py ...
- 在python中正确的赋值语句为3y=x+1-在 Python 中,正确的赋值语句为 ( ) 。_学小易找答案...
[填空题]和x/=x*y+z等价的语句是 . [单选题]语句print("x=${:7.2f}".format(123.5678))执行后的输出结果是( ).选项中的 □代表空格. ...
- python中24≤2825是否合法_在下列Python语句中非法的是() (2.0分)_学小易找答案
[其它]统计一个文件中的字符数.单词数(单词由空格分隔)和行数,并将某个指定的字符串从该文件中所有出现的地方删除.程序应提示用户输入指定的文件名和要删除的字符串. [单选题]在下列Python语句中非 ...
- python中write函数_第9.7节 Python使用write函数写入文件内容
一.语法 write(data) data为要写入的数据,可以为字符串str类型,也可以是bytes类型. 返回值为实际写入的数据数,在写入数据为str类型时,该数据为实际写入的UNIOCODE字符数 ...
- python中file是什么意思中文_15_【Python学习分享文章】_file(文件)及其操作
综述 - file(文件)的含义 Python 中的 file 不止使用 PC 时所说的单个文件,比如 .txt..exe 等这类文件,也包括"打开一个网址".程序间的通信数据等, ...
最新文章
- 5、Makefile基础知识汇总(转自陈皓总述)
- 常用start_Excel VBA 基础(02.7) - 常用函数 第二部分
- Django打造大型企业官网-项目部署
- 你这么爱听歌,一定活得很难过吧 | 今日最佳
- 程序员是如何评价“双十一”的?
- 用JS写二级导航(下拉菜单)
- Centos7 使用 chronyd 进行时钟同步
- eclipse中tomcat能正常启动,但是访问不了tomcat首页(问题解决)
- Windos10+VS2019+Qt5.14+Coin3D+SoQt
- Tableau 发布到tableau online错误
- arduino atmega328P MCP4725 proteus 仿真 程序
- Qunee学习开发体会
- linux安装CAS认证服务器
- 二、大数据实践项目——数据分析与处理
- 摄影基础知识——光圈
- HR提出的面试问题参考答案
- VBS电脑信息检测器
- 使用R语言筛选数据中的重复行
- 微信帐号检测的实用小方法
- Python入门到精通(4):关系与逻辑表达式
热门文章
- 渗透测试之分享常用工具、插件和脚本(干货)
- ROS——rosdep国内源更新
- php小程序秒抢高并发,PHP 如何设计一个高并发高可用的秒杀或抢券系统
- 本科实习生软件开发一月工资_我从第一次软件开发实习中学到了什么
- OneNote桌面版偶然发现,不再是玄学的模糊搜索了
- html怎么做成多彩背景随心换,html实现像百度的首页效果一样的背景图(代码)...
- android 购物车 简书,Android仿饿了么购物车效果
- Mysql安装流程(详细图文翻译解释)
- html输入正确的文本才会跳转,可视化开发
- 花名册管理之基本概念和操作