码迷,mamicode.com
首页 > 编程语言 > 详细

Python 开平方

时间:2016-12-04 19:43:34      阅读:535      评论:0      收藏:0      [点我收藏+]

标签:使用   txt   [1]   nbsp   number   using   多个   文件读取   开平   

#!/user/bin/python3
#files :using_sys.py

f = open("filename.txt","r+")
num = f.read()
f.close()
lstnum = num.split(‘\t‘)
a,b = int(lstnum[0]),float(lstnum[1])
print(type(a),type(b))
print(a,b)
ret = a ** b
print(ret)

从文件读取基数a和指数b,运算出结果

需要考虑问题:

1. 如果数据为null

2. 大数据

3. 字母,特殊字符  使用isnumber判断

4. 文件不存在

5. 多个数字

待优化

将数据结果,换成EXEL

 

Python 开平方

标签:使用   txt   [1]   nbsp   number   using   多个   文件读取   开平   

原文地址:http://www.cnblogs.com/O1Farmer/p/6131082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!