相关疑难解决方法(0)

我怎么知道我正在使用哪个python实现?

Python有几个不同的实现:CPython,Jython,PyPy等.我想以编程方式确定运行我的代码的实现.我怎样才能做到这一点?

具体来说,写一个get_implementation_name()为我调用的函数:

impl_name = get_implementation_name()
if impl_name == "CPython":
  print "I can abuse CPython implementation details. (I'm a bad, bad man.)"
elif impl_name == "PyPy":
  print "Can't count on reference-counting garbage collection here..."
else:
  print "I better be careful..."
Run Code Online (Sandbox Code Playgroud)

python cpython

43
推荐指数
2
解决办法
8568
查看次数

在python中将字符串/字符转换为整数

我想将字符串的单个字符转换为整数,向其中添加2,然后将其转换回字符串.因此,A变为C,K变为M等.

python string integer

14
推荐指数
2
解决办法
6万
查看次数

标签 统计

python ×2

cpython ×1

integer ×1

string ×1