文件操作

fr = open ('win.txt',mode='r',encoding='utf-8')
win=fr.read()
print('明文:'+ win)
print('密文:',end='')
for c in win:
    print(chr(ord(c)+3),end='')

fw = open('bili.txt',mode ='a',encoding='utf-8')
for c in win:
    print(chr(ord(c)+3,),end='')
    fw.write(chr(ord(c)+3))

fr.close()
fw.close()

name1 = 'phone'
name2 = 'ball'
superman = ['strong','handsome','tall','humorous']

print(superman[0])
print(superman[-2])
print(len(superman),superman)

文件操作_第1张图片

superman.append('bay')
superman.insert(1,'jack')

superman.pop(0)
superman.pop(-1)

superman[0]='pig'

你可能感兴趣的:(文件操作)