操作系统接口os 模块提供了很多与操作系统交互的函数:>>> import os >>> os.getcwd() # Return the current working directory 'C:\\Python34' >>> os.chdir('/server/accesslogs') # Change current working directory >>> os.
除了前面介绍的while语句,Python 还从其它语言借鉴了一些流程控制功能,并有所改变。if 語句也许最有名的语句类型是 if 语句。例如>>> x = int(input("Please enter an integer: "))Please enter an integer: 42>>> if x < 0:... x = 0... print('Negative changed to zero')... elif x == 0:... print('Zero')...