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

时间:2024-05-25 12:34:08

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.

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

3.