安装目录为"d:\ python2.7",每次打开IDLE并单击菜单File和Open项时,默认目录也是"d:\ python2.7".所以我必须将目录更改为我想要的位置.
有什么方法可以改变它吗?使用配置文件还是更改环境变量?
我试图在环境变量中添加PYTHONPATH,但它不起作用.我也导入os,并使用os.chdir(),但它只更改工作目录,而不是我想要的.
谢谢.
我想将一些文件复制到不同的USB磁盘中,并希望使用START打开几个控制台,如下所示:
start copy a.txt h:
start copy a.txt i:
start copy a.txt j:
Run Code Online (Sandbox Code Playgroud)
但每次运行批处理文件时,都有3个控制台没有退出.如何在不使用3个批处理文件和"调用"命令的情况下实现此EXIT功能:
copy.bat:
call a.bat
call b.bat
call c.bat
exit
Run Code Online (Sandbox Code Playgroud)
和三个称为批处理文件:
一只蝙蝠:
start copy a.txt h:
exit
Run Code Online (Sandbox Code Playgroud)
b.bat:
start copy a.txt i:
exit
Run Code Online (Sandbox Code Playgroud)
C.BAT:
start copy a.txt j:
exit
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个,但它不起作用:
start copy a.txt h: && exit
start copy a.txt i: && exit
start copy a.txt j: && exit
Run Code Online (Sandbox Code Playgroud) class Point(object):
def __init__(self, x=0, y=0):
self.__x = x
self.__y = y
print 'point ({x},{y}) created.'.format( x=self.__x, y=self.__y )
class Line(object):
def __init__(self, start_point=Point(), end_point=Point()):
print 'Line.__init__ called.'
self.start = start_point
self.end = end_point
def test_line():
p1 = Point(1,1)
p2 = Point(2,2)
line1 = Line(p1, p2)
if __name__=='__main__':
test_line()
Run Code Online (Sandbox Code Playgroud)
当我运行此脚本时,它会给出结果:
point (0,0) created.
point (0,0) created.
point (1,1) created.
point (2,2) created.
Line.__init__ called.
Run Code Online (Sandbox Code Playgroud)
我不知道为什么在创建line1之前调用Point .__ init().