'''
original_file = open("original.txt", "r", encoding="utf-16-be")
'''
控制台中出现的错误- '''
import matplotlib.pyplot as plt
import matplotlib.patches as patches
def Circle(radius):
circle=patches.Circle((0,0),radius,facecolor='red',/
edgecolor='blue',linestyle='dotted',linewidth='2.2')
plt.gca().add_patch(circle)
plt.plot(circle)
plt.axis('axis')
plt.title('Circle')
plt.grid()
plt.show()
def main():
radius=float(input('Enter the radius:'))
Circle(radius)
main()
''' 上面提到的代码有什么错误?
答案 0 :(得分:0)
import matplotlib.pyplot as plt
#import matplotlib.patches as patches
def Circle(radius):
circle=plt.Circle((0,0),radius,facecolor='red', edgecolor='blue',linestyle='dotted',linewidth='2.2')
plt.gca().add_patch(circle)
plt.plot()
#plt.axis('axis')
plt.title('Circle')
plt.grid()
plt.show()
def main():
radius=float(input('Enter the radius:'))
Circle(float(radius))
main()
答案 1 :(得分:0)
您正在做的事情的简化版本:
def circle():
radius = float(input('Enter the radius:'))
circle=plt.Circle((0,0),radius,facecolor='red',
edgecolor='blue',linestyle='dotted',linewidth='2.2')
plt.gca().add_patch(circle)
plt.plot(circle)
plt.axis('axis')
plt.title('Circle')
plt.grid()
plt.show()
circle()
主要区别:
plt