Discuss / Python / print

print

Topic source

zx_sunrise

#1 Created at ... [Delete] [Delete and Lock User]

for line in f.readlines(): print(line.strip()) # 把末尾的'\n'删掉 应改为: for line in f.readlines(): print(line, end='') 是print自动加了回车,而不应该把内容去回车 这样下面代码才正确 with open('test.txt', 'r') as f:

# read(byte):读取指定字节的数据
t = f.read(8)
while t:
    print(t, end='')
    t = f.read(8)

  • 1

Reply