摘要:
class MyExcept(Exception): def __init__(self, msg): self.message = msg def __str__(self): return self.message try: raise MyExcept("我的异常") except MyExcept as e: prin... 阅读全文
posted @ 2019-02-13 23:39
^sun^
阅读(172)
评论(0)
推荐(0)
摘要:
try: print("-------") open('123.txt', 'r') except (IOError, NameError): print("######") pass try: open('1.txt','r') except: print("异常") try: # open('1.txt', 'r') p... 阅读全文
posted @ 2019-02-13 23:38
^sun^
阅读(116)
评论(0)
推荐(0)
摘要:
def replace_string(my_str, *args): """ 替换字符串 :param my_str: :param args: :return: """ print(args) length = len(args) for i in range(0, length-1, 2): new_st... 阅读全文
posted @ 2019-02-13 23:36
^sun^
阅读(218)
评论(0)
推荐(0)
摘要:
import os root_path1 = r'D:\python_code' file_count = 0 dir_count = 0 def list_files(root_path): """ 遍历目录 :param root_path: :return: """ global file_count, dir_count if... 阅读全文
posted @ 2019-02-13 23:35
^sun^
阅读(189)
评论(0)
推荐(0)

浙公网安备 33010602011771号