head first python菜鸟学习笔记(第三章)

1.os.chdir()切换到指定目录下,os.getcwd(),得到当前目录。

>>> import os
>>> os.chdir('D:\\CodeDocuments\\python code\\python head first code\\03chapter3')
>>> os.getcwd()
'D:\\CodeDocuments\\python code\\python head first code\\03chapter3'

2.print(,end='')加end='',则打印时不换行,若不加,则会换行。

>>> data=open('sketch.txt')
>>> print(data.readline(),end='')
Man: Is this the right room for an argument?
>>> print(data.readline())
Other Man: I've told you once.

>>> print(data.readline())
Man: No you haven't!

>>> print(data.readline(),end='')
Other Man: Yes I have.

 

 

3.

posted @ 2017-08-31 20:27  何不呤叮  阅读(183)  评论(0编辑  收藏  举报