当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Decimal rotate()用法及代码示例


Decimal#rotate():rotate()是一个Decimal类方法,该方法返回x,y次的旋转副本

用法: Decimal.rotate()

参数:  Decimal values

返回: the rotated copy of x, y times

代码1:示例rotate()方法

# Python Program explaining  
# rotate() method 
  
# loading decimal library 
from decimal import *
  
  
# Initializing a decimal value 
a = Decimal(1) 
  
b = Decimal(2) 
  
# printing Decimal values 
print ("Decimal value a:", a) 
print ("Decimal value b:", b) 
  
  
# Using Decimal.rotate() method 
print ("\n\nDecimal a with rotate() method:", a.rotate(b)) 
  
print ("Decimal b with rotate() method:", b.rotate(b))

输出:


Decimal value a: 1
Decimal value b: 2


Decimal a with rotate() method: 100
Decimal b with rotate() method: 200

代码2:rotate()方法示例

# Python Program explaining  
# rotate() method 
  
# loading decimal library 
from decimal import *
  
  
# Initializing a decimal value 
a = Decimal(300) 
  
b = Decimal(15) 
  
  
# printing Decimal values 
print ("Decimal value a:", a) 
print ("Decimal value b:", b) 
  
  
# Using Decimal.rotate() method 
print ("\n\nDecimal a with rotate() method:", a.rotate(b)) 
  
print ("Decimal b with rotate() method:", b.rotate(b))

输出:

Decimal value a: 300
Decimal value b: 15


Decimal a with rotate() method: 300000000000000000
Decimal b with rotate() method: 15000000000000000



相关用法


注:本文由纯净天空筛选整理自noobestars101大神的英文原创作品 Python | Decimal rotate() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。