小编Joh*_*ohn的帖子

如何在Python中获取函数的路径?

我想获取Python中函数的文件路径。

怎么做?

例如,

import keras.backend as K
y = K.resize_images(x, 2, 2, 'channels_last')
path = function(K.resize_images)
print(path)
#C:\Program Files\Python36\Lib\site-packages\keras\backend\tensorflow_backend.py
Run Code Online (Sandbox Code Playgroud)

谢谢。

python

5
推荐指数
2
解决办法
1098
查看次数

如何在Python中用字典替换字符串?

如何更改stringresult

string = 'John and Mary are good friends'
d = {'John': 'Sam', 'Mary': 'Ann', 'are': 'are not'}

result = 'Sam and Ann are not good friends'
Run Code Online (Sandbox Code Playgroud)

谢谢。

python

-1
推荐指数
1
解决办法
48
查看次数

标签 统计

python ×2