摘要:
一、读取文件 1、读取整个文件 file_name = 'cat.txt' with open(file_name) as file_object: contents = file_object.read() print(contents) 2、逐行读取,可使用for循环 file_name = ' 阅读全文
摘要:
一、创建一个简单的类 二、给属性默认值 2、通过方法修改属性的值。 阅读全文
摘要:
一、简单函数的结构 def greet_user(): '''问候用户''' print(Hello,John!") greet_user() 执行结果: 二、向函数传递信息 def greet_user(username): '''问候用户''' print(‘’Hello!"+username) 阅读全文