python編程100例 python如何輸出傳入當(dāng)前函數(shù)的變量名字?
python如何輸出傳入當(dāng)前函數(shù)的變量名字?#要獲取函數(shù)外部的函數(shù)名,可以使用uuuuuuuuuuuuuuuuuuuuu獲取它。def test_u2;func_2;name1():print(“te
python如何輸出傳入當(dāng)前函數(shù)的變量名字?
#要獲取函數(shù)外部的函數(shù)名,可以使用uuuuuuuuuuuuuuuuuuuuu獲取它。
def test_u2;func_2;name1():
print(“test”)
func_2;name1=test_2;func_2;name1。2; name_2;要獲取函數(shù)中當(dāng)前函數(shù)的名稱,您可以使用sysugetframe().fu代碼.co要獲取的名稱
import sys
def testufuncuname2():
print(sys.uGetFrame().fu)代碼.co名稱)
查看變量類型的python內(nèi)置函數(shù)?
示例說明:
內(nèi)置函數(shù)isinstance(對(duì)象,(類型1,類型2))
isinstance(“內(nèi)容”,STR)
返回true或false
使用內(nèi)置函數(shù)類型(object)
print(type(1))
print(type(“content”)
output
<type“int”>?return shaping
<type“STR”>?return string