上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 60 下一页
摘要: os.path.dirname(path) # 返回文件所在的目录. import os.path print(os.path.dirname(__file__)) 打印结果: D:/Avicii/Api_Test/testcases 阅读全文
posted @ 2022-09-29 01:10 Avicii_2018 阅读(70) 评论(0) 推荐(0)
摘要: os.getcwd()获取当前文件所在文件夹的路径 os.path.realpath(__file__)获取当前文件的路径. 注: 可以看出__file__表示了当前文件的path import os.path print(os.getcwd()) print(os.path.realpath(__ 阅读全文
posted @ 2022-09-29 01:00 Avicii_2018 阅读(22) 评论(0) 推荐(0)
摘要: 1. 处理对象是string 字符串 2. 遍历去除首尾指定字符串 str = '123abcd321' a = str.strip('123') print(a) 打印结果: abcd str = '12a3abcd321' a = str.strip('123') print(a) 打印结果: 阅读全文
posted @ 2022-09-29 00:45 Avicii_2018 阅读(56) 评论(0) 推荐(0)
摘要: 日志模块log_utils.py import logging # 创建一个日志器 logger = logging.getLogger() # 设置日志打印级别. 打印该级别及以上的日志信息. logger.setLevel(logging.DEBUG) # 创建指定的输出格式 format = 阅读全文
posted @ 2022-09-29 00:04 Avicii_2018 阅读(30) 评论(0) 推荐(0)
摘要: sys.path.append() 添加临时目录, 临时有效, 且只对当前程序有效. 引入某个模块, 运行脚本时提示 no module name 'xxx', 是python程序运行时搜索不到该模块所在的目录.解决办法: # 添加临时目录 sys.path.append('../utils/log 阅读全文
posted @ 2022-09-28 23:48 Avicii_2018 阅读(241) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 60 下一页