摘要: eg: s="hello" 想让s变成"Hello",此时可以考虑函数 capitalize() 可以让第一个字母大写 print(s.capitalize()) 阅读全文
posted @ 2018-09-10 17:46 二师兄不讲英文 阅读(890) 评论(0) 推荐(0) 编辑
摘要: 例如: x=" hello " 此时,如果想去掉hello前后的空格,可以使用函数 strip() z=x.strip() print(z) 得到的结果就是"hello" 阅读全文
posted @ 2018-09-10 17:42 二师兄不讲英文 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 很简单,举个栗子, 如果import math的话,使用函数的时候必须 math.sqrt(x) 就是必须用包名.函数名 而from..import的话就直接使用函数名就可以了 from math import * 此时可以直接使用 sqrt(x)。 阅读全文
posted @ 2018-09-10 17:29 二师兄不讲英文 阅读(449) 评论(0) 推荐(0) 编辑