随笔分类 - 《笨办法学python》
摘要:类class和对象object: 假设你有一只水桶,里边有三条泥鳅。你给它们分别取名叫小方,小斌,小星 “类(class)”,泥鳅是 一个“类(class)”,而小方是一个“对象(object)” “类”,表示它不是一个真正的东西,而是一个用来描述具有同类属性的 实例的概括性词汇。 你有鳍?你有鳔?
阅读全文
摘要:from os.path import exists print(f"Does the output file exist? {exists(to_file)}") exists: 将文件名字符串作为参数,如果文件存在返回True;否则False
阅读全文
摘要:open(filename, mode, encoding=None) f = open('workfile', 'w', encoding='utf-8') 第一个实参是文件名字符串,第二个实参是包含描述文件使用方式字符的字符串,包括: 'r'表示文件只能读取;'w'表示只能写入(现有同名文件会被
阅读全文
摘要:from sys import argv script, first, second, third = argv print("The script is called:", script) print("Your first variable is:", first) print("Your se
阅读全文
摘要:mac命令:pydoc input windows:python -m pydoc input 作用:查看input函数用法 输入q退出
阅读全文