Linux-来操作文件吧 2020-07-21 0x01 文件目录管理命令touch 命令 用于创建空白文件或设置文件的时间(黑客常在修改完文件后,将修改时间调回) 创建空白文件touch 1.txt 设置文件的时间-a 仅修改“读取时间“ -m 仅修改”修改时间“ -d 用时修改”读取和修改时间” ↓ View All
JSONの初见 2020-07-18 0x01 json.dump()和json.load() json.dump存储import json numbers = [1,2,3,4,5] filename = 'num.json' with open(filename, 'w') as f_ob: json.dump(numbers, f_ob) ↓ View All
python-文件和异常 2020-07-17 0x01 从文件中读取数据 读取整个文件with open('1.txt') as file_ob: contents = file_ob.read() print(contents) with会在文件不需要访问后,将其关闭;这样的输出最后会多一个空行,因为read()到达文件末尾会返回一个空字符串,而将空字符串打印出来时就会成为一个空行,可以使用rstrip()删除 ↓ View All
python-函数 2020-07-12 0x00定义函数def echo_hi(): """打招呼""" print("Hello!") echo_hi() 三引号(三个单引号或者双引号)之间的文档字符串,python会为这个函数生成文档 ↓ View All
python-while循环和用户输入 2020-07-12 0x01 input()简介让程序暂停运行,等待用户的输入,并可以接受一个参数用来提醒用户操作,获取输入后,将其存储到一个变量之中。 message = input("Tell me something:") print(message) ↓ View All
python-操作列表 2020-07-06 0x01 遍历整个列表for循环代码names = ["a" , "b" , "c"] for name in names: print(name) 定义一个for循环,从列表names取出一个名字储存在变量name中,然后打印出来,注意冒号和缩进。 ↓ View All
python-组织列表 2020-07-03 0x01 使用sort()对列表进行永久性排序按照字母顺序排序,且是永久性排序;可选参数reverse=True,按照相反的字母顺序排序; 代码names = ['bxx', 'ayy' , 'cdd'] names.sort() print(names) names.sort(reverse = True) print(names) ↓ View All