python 获取当前运行的 class 和 方法的名字
# coding=utf-8 import sys
class Hello(): def hello(self):
print('the name of method is ## {} ##'.format(sys._getframe().f_code.co_name))
print('the name of class is ## {} ##'.format(self.__class__.__name__)) if __name__ == "__main__":
h = Hello()
h.hello()
python 获取当前运行的 class 和 方法的名字的更多相关文章
- Python获取程序运行目录和脚本目录
Python获取程序运行目录和脚本目录 import os import sys #获取脚本所在目录 print os.path.split( os.path.realpath( sys.argv[0 ...
- python 获取当前运行的类名函数名
import inspect def get_current_function_name(): return inspect.stack()[1][3] class MyClass: def func ...
- Python获取脚本所在目录的正确方法(转)
1.以前的方法如果是要获得程序运行的当前目录所在位置,那么可以使用os模块的os.getcwd()函数.如果是要获得当前执行的脚本的所在目录位置,那么需要使用sys模块的sys.path[0]变量或者 ...
- 编写python程序和运行.py文件的方法步骤
前提:已安装好 Subliume Test 3 且已经添加好python编译系统,已安装好python3.7 一.新建一个文本文档,将后缀名改为.py 二.使用 Subliume Test 3 打开该 ...
- python 获取本机ip地址的方法(Unix 平台)
#!/usr/bin/python import socket import fcntl import struct def get_ip_address(ifname): s = socket.so ...
- python 获取类中除内置方法外的所有方法名
#!/usr/bin/env python# !-*- coding:utf-8 -*- class Menu: def __init__(self): pass def updateProject( ...
- python获取网页信息的三种方法
import urllib.request import http.cookiejar url = 'http://www.baidu.com/' # 方法一 print('方法一') req_one ...
- python获取当前运行程序的名字
import os filename = os.path.abspath(__file__) print filename 打印结果: E:\bluedon\test.py
- python 获取文件运行路径
import os print(os.getcwd()) print("/".join(os.path.dirname(os.path.abspath(__file__)).spl ...
随机推荐
- 8.1.3 在BroadcastReceiver中启动Service
2010-06-21 16:57 李宁 中国水利水电出版社 字号:T | T <Android/OPhone开发完全讲义>第8章Android服务,本章主要介绍了Android系统 中的服 ...
- Session值的存储与删除
private static void SetSession<T>(string key, T val) { HttpContext.Current.Session[key] = (T)v ...
- Mysql中处理1970年前的日期(unixtime为负数的情况)负数时间戳格式化
客户扔过来一个bug,说是一个系统中对42岁以上的人的统计不正确,而41岁以下的人没有问题.眼睛瞟了一下托盘区里的日期,2012年3月26日,嗯,今年42岁的话,那么应该就是出生在1970年左右,马上 ...
- [ci]持续集成系列
持续集成一直很蛋疼,感觉没底. 几个方面来写 1,搭建gitlab 配邮箱 域名等使之好用 2,搭建jenkins –yum,安装常见插件 3,搭建sonar,汉化 4,安装sonar-scanner ...
- nodejs学习之简单服务器的编写
不废话了!直接上代码: var http = require('http'); //导入模块http http.createServer(function(request,response){ res ...
- [c#.Net] NUnit Test 体验
NUit Test Adapter 安装,两种方式 第一种:从扩展和更新里搜索nunit,进行下载安装
- linq基础,正则表达式,.net相关
声明扩展方法的步骤:类必须是static,方法是static,第一个参数是被扩展的对象,前面标注this.使用扩展方法的时候必须保证扩展方法类已经在当前代码中using. LINQ:将int数组中大 ...
- 使用MyBatis_Generator生成Dto、Dao、Mapping
由于MyBatis属于一种半自动的ORM框架,所以主要的工作将是书写Mapping映射文件,但是由于手写映射文件很容易出错,所以查资料发现有现成的工具可以自动生成底层模型类.Dao接口类甚至Mappi ...
- MapReduce源码分析之作业Job状态机解析(一)简介与正常流程浅析
作业Job状态机维护了MapReduce作业的整个生命周期,即从提交到运行结束的整个过程.Job状态机被封装在JobImpl中,其主要包括14种状态和19种导致状态发生的事件. 作业Job的全部状态维 ...
- Office Web Apps Server 2013与PDF(一)
好吧--这个消息有点旧,迟了将近4个月. Office Web Apps是微软各大服务产品系列中的一个基础服务,可以为SharePoint 2013.Exchange 2013.Lync 2013提供 ...