![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
五岁就抬头
这个作者很懒,什么都没留下…
展开
-
Python 罗马数字与阿拉伯数字的转换
原文https://kingname.info/2014/12/29/%E5%AF%B9%E4%B8%80%E4%B8%AA%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97%E4%B8%8E%E9%98%BF%E6%8B%89%E4%BC%AF%E6%95%B0%E5%AD%97%E8%BD%AC%E6%8D%A2%E7%AE%97%E6%B3%95%E7%9A%84%E5转载 2017-06-28 20:38:59 · 5103 阅读 · 0 评论 -
import的注意事项
test.py#test.pydef display(): print ('hello world')display()main.pyimport test运行main.py代码会执行一次即输出hello wprld原创 2017-08-27 17:41:30 · 202 阅读 · 0 评论 -
计算文件的26个字母出现的频率
来自solelearn appdef count_char(text,char): count = 0 for c in text: if c==char: count+=1 return countfimename = input("Enter a filename:")with open(fimename) as f: ...原创 2018-04-11 12:58:02 · 2277 阅读 · 0 评论 -
python 求素数
def get_primes(): num=2 while True: if is_prime(num): #暂未实现 yield num num+=1原创 2018-04-11 13:41:31 · 484 阅读 · 0 评论 -
python文件处理(一)
1.一般写try: f = open('/path/to/file', 'r') print f.read()finally: if f: f.close()但是麻烦可以写成,不用close()了with open('/path/to/file', 'r') as f: print f.read()2. f.read()一次读取所有文件内容,量力而...原创 2018-04-07 12:18:40 · 101 阅读 · 0 评论 -
python控制浮点型小数位
一a =1.23456789b="%4.f"%a #会变成字符串二round(a,3) #四舍五入原创 2018-04-07 14:03:26 · 3894 阅读 · 0 评论 -
python3 去除字符串中的数字
来自https://stackoverflow.com/questions/12851791/removing-numbers-from-stringpython3:from string import digitss = 'abc123def456ghi789zero0'remove_digits = str.maketrans('', '', digits)res = s.transl...原创 2018-05-15 14:57:50 · 42773 阅读 · 0 评论