随笔分类 -  Head First Python notes

摘要:1. 代码 from sys import exit # 定义黄金屋函数 def gold_room(): print("This room is full of gold. How much do you take?") next = input(">") if "0" in next or "1 阅读全文
posted @ 2021-05-16 15:22 JRS077 阅读(44) 评论(0) 推荐(0) 编辑
摘要:1. 报错如下: SyntaxError: Non-UTF-8 code starting with '\xd3' in file D:\流畅学python\ex34.py on line 4, but no encoding declared; see http://python.org/dev/ 阅读全文
posted @ 2021-05-13 22:33 JRS077 阅读(2421) 评论(0) 推荐(0) 编辑
摘要:<https://www.cnblogs.com/gufengchen/p/11038029.html> 阅读全文
posted @ 2020-09-27 16:25 JRS077 阅读(325) 评论(0) 推荐(0) 编辑
摘要:1. 控制你的代码 Head First Python支持网站http://python.itcarlow.ie/resources.html,下载webapp.zip, 解压到硬盘。 点击以下红下划线链接下载。 2. CGI让Web服务器运行程序 用python打开simple_htpd.py并R 阅读全文
posted @ 2020-09-27 16:24 JRS077 阅读(171) 评论(0) 推荐(0) 编辑
摘要:http://python.itcarlow.ie/resources.html 阅读全文
posted @ 2020-09-20 22:40 JRS077 阅读(265) 评论(0) 推荐(0) 编辑
摘要:把文本文件中的数据转换为AthleteList对象实例,存储在一个字典中(按选手索引),然后保存为一个pickle文件。 # Author kevin_hou import pickle from athletelist import AthleteList def get_coach_data(f 阅读全文
posted @ 2020-09-20 19:42 JRS077 阅读(145) 评论(0) 推荐(0) 编辑
摘要:问题:from athletelist import AthleteList出现红色下滑波浪线警告 经过个人网上搜索了解,这个问题是因为python找不到相关的.py文件,无法导入athletelist.py模块。 具体操作如下: 1. athletelist->Refactor->Move->H: 阅读全文
posted @ 2020-09-20 18:04 JRS077 阅读(228) 评论(0) 推荐(0) 编辑
摘要:# Author kevin_hou def sanitize(time_string): #格式化时间 if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return (time_ 阅读全文
posted @ 2020-09-16 22:32 JRS077 阅读(242) 评论(0) 推荐(0) 编辑
摘要:# Author kevin_hou def sanitize(time_string): #将时间格式化为统一字符串格式 if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: retu 阅读全文
posted @ 2020-09-16 19:46 JRS077 阅读(113) 评论(0) 推荐(0) 编辑
摘要:# Author kevin_hou def sanitize(time_string): #将时间格式化为统一字符串格式 if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: retu 阅读全文
posted @ 2020-09-16 19:06 JRS077 阅读(115) 评论(0) 推荐(0) 编辑
摘要:建立4个txt记录数据,james.txt/julie.txt/mikey.txt/sarah.txt with open('james.txt') as jaf: #打开文件 data = jaf.readline() james = data.strip().split(',') #以逗号进行分 阅读全文
posted @ 2020-09-09 20:40 JRS077 阅读(121) 评论(0) 推荐(0) 编辑
摘要:# Author kevin_hou with open('james.txt') as jaf: data = jaf.readline() james = data.strip().split(',') with open('julie.txt') as juf: data = juf.read 阅读全文
posted @ 2020-09-09 19:19 JRS077 阅读(82) 评论(0) 推荐(0) 编辑
摘要:strip() 方法可以从字符串去除不想要的空白符。 print() BIF的file参数控制将数据发送/保存到哪里。 finally组总会执行,而不论try/except语句中出现什么异常。 会向except组传入一个异常对象,并使用as关键字赋至一个标识符。 str() BIF可以用来访问任何数 阅读全文
posted @ 2020-09-07 21:30 JRS077 阅读(161) 评论(0) 推荐(0) 编辑
摘要:names = ['A','B','C',['D','E'],['F']] def print_lol(the_list,indent=False,level=0): # for each_item in the_list: if isinstance(each_item,list): print_ 阅读全文
posted @ 2020-09-06 12:29 JRS077 阅读(158) 评论(0) 推荐(0) 编辑
摘要:# Author kevin_hou movies = ["The Holy Grail", 1975, "Terry Jones & Terry Gilliam",91, ["Graham Chapman", ["Michel Palin","John Cleese", "Terry Gillia 阅读全文
posted @ 2020-09-01 23:08 JRS077 阅读(487) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示