摘要:
方法一: path='d:/NEWS.txt' #以写模式打开路径文件,若不存在则创建,存在则覆盖,写入nihao f=open(path,'w') f_name.write('NIHAO') #以读模式打开路径文件 f_name=open(path,'r') #读取文件 f_name.read() 阅读全文
posted @ 2020-03-18 21:08
爬爬QQ
阅读(319)
评论(0)
推荐(0)
摘要:
In [197]: float('1.2345') Out[197]: 1.2345 In [198]: float('something') ValueError Traceback (most recent <ipython-input-198-439904410854> in <module> 阅读全文
posted @ 2020-03-18 20:45
爬爬QQ
阅读(2047)
评论(0)
推荐(0)
摘要:
enumerate函数 ,Python内建了⼀个enumerate函数,可以返 回(i, value)元组序列: for i, value in enumerate(collection): # do something with value 当你索引数据时,使⽤enumerate的⼀个好⽅法是计算 阅读全文
posted @ 2020-03-18 16:12
爬爬QQ
阅读(516)
评论(0)
推荐(0)
摘要:
1.另外一种格式化方法: template = '{0:.2f} {1:s} are worth US${2:d}' {0:.2f}表示格式化第⼀个参数为带有两位⼩数的浮点数。 {1:s}表示格式化第⼆个参数为字符串。 {2:d}表示格式化第三个参数为⼀个整数。 template.format(4. 阅读全文
posted @ 2020-03-18 14:37
爬爬QQ
阅读(134)
评论(0)
推荐(0)