随笔分类 -  python学习

1 2 3 4 5 ··· 11 下一页
个人学习使用,所有收集仅供参考。
摘要: 阅读全文
posted @ 2019-07-31 22:49 樊伟胜 阅读(200) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:48 樊伟胜 阅读(106) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:46 樊伟胜 阅读(167) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:45 樊伟胜 阅读(203) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:44 樊伟胜 阅读(193) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:42 樊伟胜 阅读(119) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:42 樊伟胜 阅读(115) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:41 樊伟胜 阅读(135) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:40 樊伟胜 阅读(616) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-07-31 22:39 樊伟胜 阅读(162) 评论(0) 推荐(0)
摘要:import shutil import os import os.path src = " d:\\download\\test\\myfile1.txt " dst = " d:\\download\\test\\myfile2.txt " dst2 = " d:/download/test/测 阅读全文
posted @ 2019-07-25 14:10 樊伟胜 阅读(521) 评论(0) 推荐(0)
摘要:import os.path # 常用函数有三种:分隔路径,找出文件名.找出盘符(windows系统),找出文件的扩展名. # 根据你机器的实际情况修改下面参数. spath = " D:/download/repository.7z " # case 1: p,f = os.path.split( 阅读全文
posted @ 2019-07-25 14:09 樊伟胜 阅读(10299) 评论(0) 推荐(0)
摘要:import os import os.path # os,os.path里包含大多数文件访问的函数,所以要先引入它们. # 请按照你的实际情况修改这个路径 rootdir = " d:/download " for parent, dirnames, filenames in os.walk(ro 阅读全文
posted @ 2019-07-25 14:07 樊伟胜 阅读(589) 评论(0) 推荐(0)
摘要:每一个.py文件称为一个module,module之间可以互相导入.请参看以下例子: # a.py def add_func(a,b): return a+b # b.py from a import add_func # Also can be : import a print ("Import  阅读全文
posted @ 2019-07-25 14:06 樊伟胜 阅读(208) 评论(0) 推荐(0)
摘要:class Base: def __init__(self): self.data = [] def add(self, x): self.data.append(x) def addtwice(self, x): self.add(x) self.add(x) # Child extends Ba 阅读全文
posted @ 2019-07-25 14:05 樊伟胜 阅读(229) 评论(0) 推荐(0)
摘要:#! /usr/bin/python s=input("Input your age:") if s =="": raise Exception("Input must no be empty.") try: i=int(s) except Exception as err: print(err) 阅读全文
posted @ 2019-07-25 14:04 樊伟胜 阅读(490) 评论(0) 推荐(0)
摘要:对比Java,python的文本处理再次让人感动 #! /usr/bin/python spath="D:/download/baa.txt" f=open(spath,"w") # Opens file for writing.Creates this file doesn't exist. f. 阅读全文
posted @ 2019-07-25 14:04 樊伟胜 阅读(356) 评论(0) 推荐(0)
摘要:#! /usr/bin/python # -*- coding: utf8 -*- def sum(a,b): return a+b func = sum r = func(5,6) print (r) # 提供默认值 def add(a,b=2): return a+b r=add(1) prin 阅读全文
posted @ 2019-07-25 14:03 樊伟胜 阅读(360) 评论(0) 推荐(0)
摘要:比起C/C++,Python处理字符串的方式实在太让人感动了.把字符串当列表来用吧. #! /usr/bin/python word="abcdefg" a=word[2] print ("a is: "+a) b=word[1:3] print ("b is: "+b) # index 1 and 阅读全文
posted @ 2019-07-25 14:02 樊伟胜 阅读(565) 评论(0) 推荐(0)
摘要:#! /usr/bin/python #条件和循环语句 x=int(input("Please enter an integer:")) if x<0: x=0 print ("Negative changed to zero") elif x==0: print ("Zero") else: pr 阅读全文
posted @ 2019-07-25 14:02 樊伟胜 阅读(244) 评论(0) 推荐(0)

1 2 3 4 5 ··· 11 下一页