python 獲取當前函式的 函式名 sys._getframe().f_code.co_name
# -*- coding:utf-8 -*-
import sys
class test_class():
def hello(self):
print(sys._getframe().f_code.co_name)
def hello_world():
print('hello_world!')
print(sys._getframe().f_code.co_name)
if __name__ == '__main__':
ttt = test_class()
ttt.hello()
hello_world()
hello hello_world! hello_world Process finished with exit code 0
--------------------- 本文來自 HeatDeath 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/HeatDeath/article/details/72844487?utm_source=copy
相關推薦
python 獲取當前函式的 函式名 sys._getframe().f_code.co_name
# -*- coding:utf-8 -*- import sys class test_class(): def hello(self): print(sys._getframe().f_code.co_name) def hello_wor
python 獲取當前函式名和行號
sys._getframe([depth]) Return a frame object from the call stack. If optional integer depth is given, return the frame object that many
【python系列】python 獲取當前位置所在的檔名、函式名和行號
import sys def get_cur_info(): print sys._getframe().f_code.co_filename #當前檔名,可以通過__file__獲得 print sys._getframe().f_code.co_name #當前函式名 pri
python 獲取當前目錄下的文件目錄和文件名
文件目錄 spl list tdi files 文件的 span 兩個 utf os模塊下有兩個函數: os.walk() os.listdir() 1 # -*- coding: utf-8 -*- 2 3 import os
Python獲取當前檔名分兩種方法:__file__、sys.argv[0]
Python獲取當前檔名可以通過__file__或者sys.argv[0],下面以test.py檔案為例. test.py: # -*- coding: utf-8 -*- # test.py import sys import os # 絕對路徑 print(__fi
【python】python獲取當前日期前後N天或N月的日期
color ont mes form localtime col r+ arr nth 1 # -*- coding: utf-8 -*- 2 3 ‘‘‘獲取當前日期前後N天或N月的日期‘‘‘ 4 5 from time import strfti
Python獲取當前時間或者當前時間戳【轉】
想要 模塊 str 相關 月份 import pri 根據 min 取得時間相關的信息的話,要用到python time模塊,python time模塊裏面有很多非常好用的功能,你可以去官方文檔了解下,要取的當前時間的話,要取得當前時間的時間戳,時間戳好像是1970年到現在
python獲取當前時間和前一天時間
import 時間 ftime date time 格式化 %d str RF datetime ime模塊:import timetime.strftime(‘%Y%m%d‘) //time.strftime(‘%Y-%m-%d-%H:%M:%S‘) //獲取了當前時間
【Python】-006 python獲取當前系統所有程序pid與名稱
【Python】-006 python獲取當前系統所有程序pid與名稱 【Python】-006 python獲取當前系統所有程序pid與名稱 1、實現 2、注意 1、實現
python獲取當前時間用GUI介面顯示
程式執行效果圖: 有兩種方法,執行效果一樣 方法一:利用configure()或config()方法實現文字變化 # 方法一:利用configure()或config()方法實現文字變化 import tkinter import time def gettime():
Python獲取當前資料夾下的目錄和檔案
Python獲取當前資料夾下的目錄和檔案 # !/usr/bin/env python # -*-coding:utf-8-*- """ Copyright(c)2018 file: sambaCenter.py author: date
python 獲取當前資料夾路徑及父級目錄的幾種方法
獲取當前資料夾路徑及父級目錄: import os current_dir = os.path.abspath(os.path.dirname(__file__)) print(current_dir) #F:\project\pritice current_dir1 = os.path.dirna
Python獲取當前路徑
Refs: 假設py檔案路徑為 F:/SEG/myResearch/myProject_2/test.py Method 1: sys.argv[0] import sys print sys.argv[0]#獲得的是當前執行指令碼的位置(若在命令列執行的該命令
python 獲取當前檔案的指定型別的檔名
import os def getFiles(): files = os.listdir(os.getcwd()) # os.getcwd() 獲取當前檔案的路徑 print(files) filesList = [] fo
Python 獲取當前時間的前一個月,和前一個星期的時間列表
1.獲取前一個星期的時間列表 def dateRange(beginDate): """ 設計時間格式,也就是取出今天前七天的時間列表 :param beginDate: :return: """ yes_time = beginDate + da
Android獲取當前的城市名的方法
/** Called when the activity is first created. */ /** 上下文 */ private BMapApiApplication mApplication; /** 定義搜尋服務類 */ private MKSearch mMKSearch
python 獲取當前目錄下的檔案目錄和檔名 python 獲取當前目錄下的檔案目錄和檔名
python 獲取當前目錄下的檔案目錄和檔名 os模組下有兩個函式: os.walk() os.listdir() 1 # -*- coding: utf-8 -*- 2
python獲取當前日期時間
轉載自:https://www.cnblogs.com/wenBlog/p/6023742.html 在Python裡如何獲取當前的日期和時間呢?在Python語言裡,我們可以通過呼叫什麼模組或者類函式來得到當前的時間或日期呢? 當然你可以使用時間模組(time module),該模組提供了各種和時間相關
python獲取當前時間和時間戳以及時間的加減
#coding=utf-8 import datetime import time now=datetime.datetime.now() d2 = datetime.datetime.strptime(now.strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%
python-獲取當前工作路徑
sys.argv[0] import sys print sys.argv[0]#獲得的是當前執行指令碼的位置(若在命令列執行的該命令,則為空) 執行結果(在python指令碼中執行的結果):