- 博客(5)
- 收藏
- 关注
原创 那些错误
invalid character in identifier 有中文空格 (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 在Python中\是转义符,\u表示其后是UNICODE编码,因此\User在这里会报错,在字符串前面加个r表示就可...
2018-11-14 09:37:44
113
1
转载 将函数存储在模块之中
import name 导入模块 from name import pizza_name 从模块中导入函数 from name import pizza_name as pm 从模块中导入函数,并取名pm import name as n 导入模块,并取名n from name import * 导入模块中的全部函数 ...
2018-11-13 11:18:11
171
1
原创 函数合集
name.title() 首字母大写 name.upper() 全部大写 name.lower() 全部小写 name.strip() 删除字符串首尾的空格 name.rstrip() 删除字符串末尾的空格 name.lstrip() 删除字符串开头的空格 列表: name.append() 列表末尾添加元素 name.insert(' ', ' ') 在列表的具体位置添加元素 ...
2018-11-06 11:26:37
261
原创 习题41:学习面向对象术语
import random from urllib.request import urlopen import sys WORD_URL = "http://learncodethehardway.org/words.txt" WORDS = [] PHRASES = { "class %%%(%%%):": # 创建一个叫X的类。它是Y的一种 "Make a cl...
2018-10-30 10:44:19
287
原创 习题26 恭喜你,你现在可以考试了!
源代码(标错不完整) def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return
2018-10-16 17:17:42
430
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人