我在python中编写了一个海龟程序,但有两个问题.
到目前为止这是我的代码:
import turtle
#Takes user input to decide how many squares are needed
f=int(input("How many squares do you want?"))
c=int(input("What colour would you like? red = 1, blue = 2 and green =3"))
n=int(input("What background colour would you like? red = 1, blue = 2 and green =3"))
i=1
x=65
#Draws the desired number of squares.
while i < f:
i=i+1
x=x*1.05
print ("minimise this window ASAP")
if c==1:
turtle.pencolor("red")
elif c==2:
turtle.pencolor("blue")
elif c==3:
turtle.pencolor("green")
else: …Run Code Online (Sandbox Code Playgroud) 使用pickle函数是将整数写入文本文件的最快且最强大的方法吗?
这是我到目前为止的语法:
import pickle
pickle.dump(obj, file)
Run Code Online (Sandbox Code Playgroud)
如果有更强大的替代方案,请随时告诉我.
我的用例是写一个用户输入:
n=int(input("Enter a number: "))
Run Code Online (Sandbox Code Playgroud)