问题描述
我输入:4.2
#include <iostream>
using namespace std;
int main()
{
double a;
double b;
cout<<"Enter the number of light year : ";
cin>>a;
b = a * 63241;
cout<<b;
return 0;
}
解决方法
您需要“操纵”输出流(
import tkinter as tk
from PIL import Image,ImageTk
import windnd
class Text(tk.Text):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.gif = {}
self.frame_index = 0
self.delay = 10
def changeCursor(self,event):
if event.type == '7':
self.configure(cursor="hand2")
else:
self.configure(cursor="xterm")
def insert_gif(self,path):
gif = GifMaker(path)
index = self.image_create("end",image=gif.frames[0])
self.tag_add(f"{index}",'end-2c')
self.gif[index] = gif
self.tag_bind(f"{index}","<1>",lambda event: self.playGif(index))
self.tag_bind(f"{index}","<Enter>",self.changeCursor)
self.tag_bind(f"{index}","<Leave>",self.changeCursor)
self.playGif(index)
def playGif(self,label):
self.frame_index += 1
self.image_configure(label,image=self.gif[label].frames[self.frame_index])
if self.frame_index == self.gif[label].n_frames-1:
self.frame_index = 0
self.image_configure(label,image=self.gif[label].frames[0])
if self.frame_index != 0:
#self.after(self.gif[label].delay,self.playGif,label)
self.after(self.delay,label)
class GifMaker:
def __init__(self,path):
self.path = path
self.image = Image.open(path)
self.n_frames = self.image.n_frames # number of frames
self.frames = []
self.duration = 0 # total duration of the gif
for x in range(self.n_frames):
img = ImageTk.PhotoImage(self.image.copy())
self.duration += self.image.info['duration']
self.frames.append(img)
self.image.seek(x)
self.delay = self.duration//self.n_frames
def dropped(file):
text.insert_gif(file[0])
root = tk.Tk()
text = Text()
text.pack(fill='both',expand=True)
windnd.hook_dropfiles(root,func=dropped)
root.mainloop()
):
std::cout