小编Mar*_*ion的帖子

使用print函数在没有'或'的情况下用Python打印一个句子

下面是我的代码,我正在使用Python2.7

#list of angle couples
phipsi=[[48.6,53.4],[-124.9,156.7],[-66.2,-30.8],[-58.8,-43.1], \
[-73.9,-40.6],[-53.7,-37.5],[-80.6,-16.0],[-68.5,135.0], \
[-64.9,-23.5],[-66.9,-45.5],[-69.6,-41.0],[-62.7,-37.5], \
[-68.2,-38.3],[-61.2,-49.1],[-59.7,-41.1],[-63.2,-48.5], \
[-65.5,-38.5],[-64.1,-40.7],[-63.6,-40.8],[-66.4,-44.5], \
[-56.0,-52.5],[-55.4,-44.6],[-58.6,-44.0],[-77.5,-39.1], \
[-91.7,-11.9],[48.6,53.4]]
#minimal deviation tolerated for the 1st number
a=-57-30
#maximal deviation tolerated for the 1st number
b=-57+30
#minimal deviation tolerated for the 2nd number
c=-47-30
#maximal deviation tolerated for the 2nd number
d=-47+30
i=0
#Check if the couple fit into the intervals of numbers
while i < len(phipsi):
    if phipsi[i][0]>a and phipsi[i][0]<b:
        if phipsi[i][1]>c and phipsi[i][1]<d:
            print ('the couple ', phipsi[i] ,' has …
Run Code Online (Sandbox Code Playgroud)

python printing python-2.7

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

ggplot2在rpy2中不存在用于python?

我在Python3.2中使用rpy2 v2.1.9,我不明白为什么我不能使用库ggplot2

import rpy2
from rpy2.robjects import r
r.library("ggplot2")
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息

Error in function (package, help, pos = 2, lib.loc = NULL, character.only = FALSE,  : 
  there is no package called 'ggplot2'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/functions.py", line 82, in __call__
     return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
   File "/usr/local/lib/python3.2/dist-packages/rpy2/robjects/functions.py", line 34, in __call__
     res = super(Function, self).__call__(*new_args, **new_kwargs)
 rpy2.rinterface.RRuntimeError: Error in function (package, help, pos = 2, lib.loc = NULL, character.only = FALSE,  : 
   there …
Run Code Online (Sandbox Code Playgroud)

python r ggplot2 rpy2 python-3.x

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

标签 统计

python ×2

ggplot2 ×1

printing ×1

python-2.7 ×1

python-3.x ×1

r ×1

rpy2 ×1