文件操作

Posted 梁梓蕙

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文件操作相关的知识,希望对你有一定的参考价值。

fr = open(\'Alice.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(\'Alice.txt\', mode=\'r\', encoding=\'utf-8\')
plaincode=fr.read()
fr.close()

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

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

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

classmates = [\'Michael\',\'Bob\',\'Tracy\']
#print(len(classmates))
#print(classmates[-1])

classmates.append(\'Rose\')
print(classmates)

classmates = [\'Michael\',\'Bob\',\'Tracy\']
#print(len(classmates))
#print(classmates[-1])

classmates.append(\'Rose\')
classmates.insert(1,\'Jack\')

classmates.pop()
print(classmates)

classmates = [\'Michael\',\'Bob\',\'Tracy\']
#print(len(classmates))
#print(classmates[-1])

classmates.append(\'Rose\')
classmates.insert(1,\'Jack\')

classmates.pop()
classmates.pop(0)
print(classmates)

classmates = [\'Michael\',\'Bob\',\'Tracy\']
#print(len(classmates))
#print(classmates[-1])

classmates.append(\'Rose\')
classmates.insert(1,\'Jack\')

classmates.pop()
classmates.pop(0)
classmates[0] =\'Tom\'
print(classmates)

import turtle
turtle.speed(10)
colors = [\'red\', \'purple\', \'blue\', \'green\', \'yellow\', \'orange\']

for i in range(100):
    turtle.pencolor(colors[i% 6])
    turtle.forward(i)
    turtle.left(59)
turtle.done()

以上是关于文件操作的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段15——git命令操作一个完整流程

VSCode 如何操作用户自定义代码片段(快捷键)

代码片段 - Golang 实现集合操作

Apollo Codegen 没有找到生成代码的操作或片段

VSCode自定义代码片段——.vue文件的模板

操作栏标签片段中的片段?