文件操作

fr = open('letter.txt', mode='r', encoding='utf-8')
plaincode = fr.read()
print('明文:'+ plaincode)

print('密文:',end='')
for c in plaincode:
    print(chr(ord(c)+3),end='')

fr = open('letter.txt', mode='r', encoding='utf-8')
plaincode = fr.read()
fr.close()

fw = open('a_letter.txt', mode='a', encoding='utf-8')
for c in plaincode:
    fw.write(chr(ord(c)+3))
fw.close()

fr = open('a_letter.txt', mode='r', encoding='utf-8')
plaincode = fr.read()
fr.close()

fw = open('letter.txt', mode='a', encoding='utf-8')
for c in plaincode:
    fw.write(chr(ord(c)-3))
fw.close()

import turtle
colors= ['#B03060','#9B30FF','#CD6889','#8470FF','#DB7093','#EE5C42']
turtle.speed(10)
for i in range(150):
    turtle.pencolor(colors[i% 6])
    turtle.forward(i)
    turtle.left(59)
turtle.done()

文件操作_第1张图片

classmates = ['Micheel','Bob','Tracy']
#print(len(classmates))
#print(classmates[1])

classmates.append('Tom')
classmates.insert(1, 'Jack')

classmates.pop()
classmates.pop(1)

classmates[1] = 'Sarah'
print(classmates)

 

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