随笔分类 -  Python

摘要:# -*- coding: utf-8 -*- """ Created on Fri Apr 30 09:19:24 2021 @author: charles """ import chardet import csv def read_csv(filename): encodings = ['g 阅读全文
posted @ 2021-04-30 10:44 zzuCharles 阅读(304) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*- """ Created on Wed Jun 12 17:28:30 2019 @author: ********** """ import sys,os kilobytes = 1024 megabytes = kilobytes*1000 chun 阅读全文
posted @ 2021-04-29 09:54 zzuCharles 阅读(90) 评论(0) 推荐(0)
摘要:def func(dep): for i in range(1, 2*dep, 2): print(('*' * i).center(2*dep-1)) for i in reversed(range(1, 2*(dep-1), 2)): print(('*' * i).center(2*dep-1 阅读全文
posted @ 2020-05-29 09:01 zzuCharles 阅读(1206) 评论(0) 推荐(0)
摘要:import os dict_suffix ={'doc':[],'docx':[], 'xls':[],'xlsx':[], 'ppt':[],'pptx':[]} def lsdir(path): for dirpath,dirnames,filenames in os.walk(path): 阅读全文
posted @ 2020-05-21 09:09 zzuCharles 阅读(639) 评论(0) 推荐(0)
摘要:Game1 def guess(armnums): number = random.randint(1, 9) chances = 0 while chances < 5: print("System guess :%d"%number) if armnums == number: print("S 阅读全文
posted @ 2020-05-11 19:51 zzuCharles 阅读(325) 评论(0) 推荐(0)
摘要:# METHOD11 from difflib import SequenceMatcher 2 def similarity(a, b): 3 return SequenceMatcher(None, a, b).ratio() 4 5 print(similarity('CharlesCC', 阅读全文
posted @ 2020-04-25 12:00 zzuCharles 阅读(6256) 评论(0) 推荐(0)
摘要:# 打印10个abcp="abc" print(p*10)# 通过参数传递 print('{greet} from {language}'.format(greet='hello', language='Python')) # 通过位置传参 print('{0} from {1}'.format(' 阅读全文
posted @ 2020-04-25 11:06 zzuCharles 阅读(218) 评论(0) 推荐(0)
摘要:def inputcheck(n): while True: try: return float(n) except: print("输入错误,输入值只能为数字:") n = input() def add(x, y): return x + y def subtract(x, y): return 阅读全文
posted @ 2020-04-24 16:50 zzuCharles 阅读(265) 评论(0) 推荐(0)