我有文件树:
f:/src/
restore.ini
config.py
log.py
service.py
test.py
test.py
代码如下:
现在,我使用命令行python test.py install
和python test.py start
来操作服务,但是出错了。在
如果我将目录src
中的所有文件移动到C:\Python27\Lib\site-packages\win32\src
,并更改代码:
self.currentRound = int(config.read_config_co(r'src\restore.ini', 'Record')['currentRound'])
config.write_config_update_co(self.currentRound-1, 'Record', 'currentRound', r'src\restore.ini')
现在,没事了!在
我不想移动目录src
,怎么办?
谢谢!在
如果对文件名或目录名使用相对路径,python将在当前工作目录(bash中的$PWD变量;在windows上类似?)中查找(或创建它们)。在
如果您想让它们相对于当前的python文件,可以使用(python3.4)
或(python 2.7)
^{pr2}$如果您的
restore.ini
文件与python脚本位于同一目录中。在那你就可以用在
相关问题 更多 >
编程相关推荐