2020-12-30

Java实现简单的计算器

要求: 编写一个Java应用程序,采用GridLayout实现如下计算机器的布局及做相应的事件处理

代码实现(本需求完全有个人实现):

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings(“serial”)
class MyComputerWin extends JFrame implements ActionListener {
JTextField expressText; //创建一个单行文本框引用
JPanel numPanel, operPanel;// 创建两个面板引用
JPanel panel; //创建一个面板用于存放文本框与"="按钮。
//创建按钮数组用于存放按钮,并定义数组的长度
JButton[] numBtn = new JButton[12];
JButton[] operBtn = new JButton[6];
String express = “”;

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
	expressText <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JTextField</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//实例化单行文本框对象</span>
	<span class="token comment">//实例化面板对象</span>
	numPanel <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JPanel</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
	operPanel <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JPanel</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	panel <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JPanel</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//设置面板为网格布局(GridLayout),  注意: 默认是流动布局(FlowLayout)</span>
	panel<span class="token punctuation">.</span><span class="token function">setLayout</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">BorderLayout</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	numPanel<span class="token punctuation">.</span><span class="token function">setLayout</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">GridLayout</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operPanel<span class="token punctuation">.</span><span class="token function">setLayout</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">GridLayout</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//将数字按钮添加到数字面板上</span>
	<span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> numBtn<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		<span class="token comment">//创建数字按钮</span>
		<span class="token keyword">if</span><span class="token punctuation">(</span>i<span class="token operator">&gt;=</span><span class="token number">0</span><span class="token operator">&amp;&amp;</span>i<span class="token operator">&lt;=</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
			numBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token punctuation">(</span><span class="token number">7</span><span class="token operator">+</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>i<span class="token operator">&gt;=</span><span class="token number">3</span><span class="token operator">&amp;&amp;</span>i<span class="token operator">&lt;=</span><span class="token number">5</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
			numBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token punctuation">(</span>i<span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>i<span class="token operator">&gt;=</span><span class="token number">6</span><span class="token operator">&amp;&amp;</span>i<span class="token operator">&lt;=</span><span class="token number">8</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
			numBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token punctuation">(</span>i<span class="token operator">-</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
			numBtn<span class="token punctuation">[</span><span class="token number">9</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token string">"00"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
			numBtn<span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token string">"0"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
			numBtn<span class="token punctuation">[</span><span class="token number">11</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token operator">+</span><span class="token string">"^"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
		numPanel<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>numBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		numBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">addActionListener</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		
	<span class="token punctuation">}</span>
	<span class="token comment">//设置符号按钮</span>
	operBtn<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"%"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"/"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"*"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"-"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"+"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">JButton</span><span class="token punctuation">(</span><span class="token string">"="</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//将符号按钮添加到符号面板上</span>
	<span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> operBtn<span class="token punctuation">.</span>length<span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		operPanel<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>operBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		operBtn<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">addActionListener</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	panel<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>expressText<span class="token punctuation">)</span><span class="token punctuation">;</span>
	panel<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>operBtn<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">,</span>BorderLayout<span class="token punctuation">.</span><span class="token constant">EAST</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	operBtn<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">addActionListener</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	

	<span class="token comment">//将文本框添加到窗口上,并设置为边界布局</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>panel<span class="token punctuation">,</span> BorderLayout<span class="token punctuation">.</span><span class="token constant">NORTH</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//将面板添加到窗口上</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>numPanel<span class="token punctuation">,</span> BorderLayout<span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>operPanel<span class="token punctuation">,</span> BorderLayout<span class="token punctuation">.</span><span class="token constant">EAST</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token function">MyComputerWin</span><span class="token punctuation">(</span>String title<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
	<span class="token keyword">super</span><span class="token punctuation">(</span>title<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setVisible</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setSize</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">,</span> <span class="token number">300</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setLocationRelativeTo</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span>expressText<span class="token punctuation">.</span><span class="token function">setBackground</span><span class="token punctuation">(</span>Color<span class="token punctuation">.</span><span class="token constant">YELLOW</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setDefaultCloseOperation</span><span class="token punctuation">(</span>JFrame<span class="token punctuation">.</span><span class="token constant">EXIT_ON_CLOSE</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

@Override
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">actionPerformed</span><span class="token punctuation">(</span>ActionEvent e<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
	String s <span class="token operator">=</span> e<span class="token punctuation">.</span><span class="token function">getActionCommand</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">//获得发生该事件的相关命令,在这里就是获得按钮事件上的数字。</span>
	express <span class="token operator">+=</span> s<span class="token punctuation">;</span> <span class="token comment">//将获得的命令保存起来</span>
	expressText<span class="token punctuation">.</span><span class="token function">setText</span><span class="token punctuation">(</span>express<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//将获得的命令放入文本框中。</span>
	<span class="token comment">//因为s代表的是单个按钮事件上的命令,所以这里判断s获得的命令是不是"="。</span>
	<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token string">"="</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>s<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		String<span class="token punctuation">[</span><span class="token punctuation">]</span> nums <span class="token operator">=</span> express<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"\\p{Punct}"</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// 5+6= 正则表达式 \\p{Punct}代表的是标点符号,这里就是通过标点符号(+,-,*,/.....)来进行分割,然后得到我们想要计算的数字。</span>
	    String<span class="token punctuation">[</span><span class="token punctuation">]</span> opers <span class="token operator">=</span>express<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"\\d+"</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//利用正则表达式中的多位数字来进行分解。然后得到我们想要的运算符号</span>
		String oper<span class="token operator">=</span>opers<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token comment">//定义一个String类型的变量存储符号</span>
		double num1<span class="token operator">=</span>Integer<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		double num2<span class="token operator">=</span>Integer<span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>nums<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	    double result<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
	    <span class="token keyword">switch</span><span class="token punctuation">(</span>oper<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		    <span class="token keyword">case</span> <span class="token string">"+"</span><span class="token punctuation">:</span>express<span class="token operator">+=</span>num1<span class="token operator">+</span>num2<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
		    <span class="token keyword">case</span> <span class="token string">"-"</span><span class="token punctuation">:</span>express<span class="token operator">+=</span>num1<span class="token operator">-</span>num2<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
		    <span class="token keyword">case</span> <span class="token string">"*"</span><span class="token punctuation">:</span>express<span class="token operator">+=</span>num1<span class="token operator">*</span>num2<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
		    <span class="token keyword">case</span> <span class="token string">"/"</span><span class="token punctuation">:</span><span class="token keyword">if</span><span class="token punctuation">(</span>num2<span class="token operator">!=</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		    	express<span class="token operator">+=</span>num1<span class="token operator">/</span>num2<span class="token punctuation">;</span>
		    	<span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
		    		express<span class="token operator">+=</span><span class="token string">"分母为0,不能计算!!"</span><span class="token punctuation">;</span>
		    	<span class="token punctuation">}</span> <span class="token keyword">break</span><span class="token punctuation">;</span>
		    <span class="token keyword">case</span> <span class="token string">"%"</span><span class="token punctuation">:</span>express<span class="token operator">+=</span>num1<span class="token operator">/</span><span class="token number">100</span><span class="token operator">*</span>num2<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
		    <span class="token keyword">case</span> <span class="token string">"^"</span><span class="token punctuation">:</span><span class="token keyword">for</span><span class="token punctuation">(</span>int i<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">&lt;</span>num2<span class="token punctuation">;</span>i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
		    			result<span class="token operator">*=</span>num1<span class="token punctuation">;</span>
		    		<span class="token punctuation">}</span> 
		    	express<span class="token operator">+=</span>result<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
	    <span class="token punctuation">}</span>
	    <span class="token comment">//express+=result;</span>
	    expressText<span class="token punctuation">.</span><span class="token function">setText</span><span class="token punctuation">(</span>express<span class="token punctuation">)</span><span class="token punctuation">;</span>
	    express<span class="token operator">=</span><span class="token string">""</span><span class="token punctuation">;</span>  <span class="token comment">//计算完之后将数据清空</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

public class MyComputer {

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span>String<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
	<span class="token keyword">new</span> <span class="token class-name">MyComputerWin</span><span class="token punctuation">(</span><span class="token string">"我的计算器"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
java 采用 java编写一个 简单 计算器,使用awt和swing

代码如下:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
i…


  <textarea class="comment-content" name="comment_content" id="comment_content" placeholder="优质评论可以帮助作者获得更高权重" maxlength="1000"></textarea>
		<div class="comment-emoticon"><img class="comment-emoticon-img" data-url="https://csdnimg.cn/release/blogv2/dist/pc/img/" src="https://csdnimg.cn/release/blogv2/dist/pc/img/emoticon.png" alt="表情包"></div> 
  <span class="comment-emoticon-tip">插入表情</span>
  <div class="comment-emoticon-box">
    <div class="comment-emoticon-img-box">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:001.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/001.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:002.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/002.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:003.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/003.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:004.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/004.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:005.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/005.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:006.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/006.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:007.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/007.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:008.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/008.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:009.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/009.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:010.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/010.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:011.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/011.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:012.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/012.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:013.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/013.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:014.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/014.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:015.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/015.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:016.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/016.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:017.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/017.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:018.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/018.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:019.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/019.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:020.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/020.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:021.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/021.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:022.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/022.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:023.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/023.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:024.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/024.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:025.png[/face]" src="https://i-blog.csdnimg.cn/blog_migrate/6fa943e149d0e77abe2bc4ea62262733.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:026.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/026.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:027.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/027.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:028.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/028.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:029.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/029.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:030.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/030.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:031.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/031.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:032.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/032.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:033.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/033.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:034.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/034.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:035.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/035.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:036.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/036.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:037.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/037.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:038.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/038.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:039.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/039.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:040.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/040.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:041.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/041.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:042.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/042.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:043.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/043.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:044.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/044.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:045.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/045.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:046.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/046.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:047.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/047.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:048.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/048.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:049.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/049.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:050.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/050.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:051.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/051.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:052.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/052.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:053.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/053.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:054.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/054.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:055.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/055.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:056.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/056.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:057.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/057.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:058.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/058.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:059.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/059.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:060.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/060.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:061.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/061.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:062.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/062.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:063.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/063.png">
        <img class="emoticon-monkey-img" data-emoticon="[face]monkey2:064.png[/face]" src="https://g.csdnimg.cn/static/face/monkey2/064.png">
    </div>
  </div>
  <div class="opt-box">
			<div id="ubbtools" class="add_code">
				<a href="#insertcode" code="code" target="_self"><i class="icon iconfont icon-daima"></i></a>
			</div>
			<input type="hidden" id="comment_replyId" name="comment_replyId">
			<input type="hidden" id="article_id" name="article_id" value="111792238">
			<input type="hidden" id="comment_userId" name="comment_userId" value="">
			<input type="hidden" id="commentId" name="commentId" value="">
			<div class="dropdown" id="myDrap">
				<a class="dropdown-face d-flex align-items-center" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
					<div class="txt-selected text-truncate">添加代码片</div>
					<svg class="icon d-block" width="200px" height="100.00px" viewBox="0 0 2048 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M597.33333292 298.666667h853.333334L1023.99999992 725.333333 597.33333292 298.666667z"></path></svg>
				</a>
				<ul class="dropdown-menu" id="commentCode" aria-labelledby="drop4">
					<li><a data-code="html">HTML/XML</a></li>
					<li><a data-code="objc">objective-c</a></li>
					<li><a data-code="ruby">Ruby</a></li>
					<li><a data-code="php">PHP</a></li>
					<li><a data-code="csharp">C</a></li>
					<li><a data-code="cpp">C++</a></li>
					<li><a data-code="javascript">JavaScript</a></li>
					<li><a data-code="python">Python</a></li>
					<li><a data-code="java">Java</a></li>
					<li><a data-code="css">CSS</a></li>
					<li><a data-code="sql">SQL</a></li>
					<li><a data-code="plain">其它</a></li>
				</ul>
			</div>
			<div class="right-box" id="rightBox" data-type="2">
						<span id="tip_comment" class="tip">还能输入<em>1000</em>个字符</span>
						<a data-report-click="{&quot;spm&quot;:&quot;3001.4374&quot;}" class="btn btn-sm btn-quick-comment" id="quickComment">“速评一下”</a>
						<a data-report-click="{&quot;mod&quot;:&quot;1582594662_003&quot;,&quot;spm&quot;:&quot;1001.2101.3001.4227&quot;,&quot;ab&quot;:&quot;new&quot;}"><input type="submit" class="btn btn-sm btn-comment" value="发表评论"></a>
			</div>
		</div>
	</form>
	<input type="button" class="bt-comment-show" value="评论">
</div>
<div class="comment-list-container" style="display: block;">
	<a id="comments"></a>
	<div class="comment-list-box"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14376181" data-replyname="weixin_43888891"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/weixin_43888891"><img src="https://profile.csdnimg.cn/A/5/2/3_weixin_43888891" username="weixin_43888891" alt="weixin_43888891" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/weixin_43888891"><span class="name ">怪咖软妹@</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">很不错分享~进步的路上一起努力!也期待您的点赞支持!</span><span class="date" title="2020-12-28 10:25:25">昨天</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14376181"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>2</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14401001" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:04:13">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14401001"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400546" data-replyname="a12355556"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/a12355556"><img src="https://profile.csdnimg.cn/B/C/0/3_a12355556" username="a12355556" alt="a12355556" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/a12355556"><span class="name ">雾进</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">内容写的很好,期待多更!</span><span class="date" title="2020-12-29 19:26:49">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400546"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400961" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:01:06">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400961"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14398787" data-replyname="weixin_44302240"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/weixin_44302240"><img src="https://profile.csdnimg.cn/E/F/1/3_weixin_44302240" username="weixin_44302240" alt="weixin_44302240" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/weixin_44302240"><span class="name ">码上代码</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">大佬,我要拜你为师!</span><span class="date" title="2020-12-29 17:09:49">17小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14398787"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400963" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:01:26">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400963"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14393883" data-replyname="weixin_44671737"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/weixin_44671737"><img src="https://profile.csdnimg.cn/E/3/5/3_weixin_44671737" username="weixin_44671737" alt="weixin_44671737" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/weixin_44671737"><span class="name ">兴趣使然的程序猿</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">写得针不戳,针不戳,来互关吧</span><span class="date" title="2020-12-29 13:14:45">21小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14393883"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400972" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:02:28">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400972"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14388335" data-replyname="kimol_justdo"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/kimol_justdo"><img src="https://profile.csdnimg.cn/E/6/2/3_kimol_justdo" username="kimol_justdo" alt="kimol_justdo" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/kimol_justdo"><span class="name ">不正经的kimol君</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">大佬就是大佬,写得很棒呀</span><span class="date" title="2020-12-29 00:34:00">昨天</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14388335"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400975" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:01:44">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400975"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14384140" data-replyname="qq_37960603"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_37960603"><img src="https://profile.csdnimg.cn/8/3/3/3_qq_37960603" username="qq_37960603" alt="qq_37960603" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/qq_37960603"><span class="name ">ITKaven</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">文章很赞,作者辛苦了!</span><span class="date" title="2020-12-28 18:05:01">昨天</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14384140"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400979" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:02:10">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400979"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14383188" data-replyname="qq_37924905"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_37924905"><img src="https://profile.csdnimg.cn/F/F/E/3_qq_37924905" username="qq_37924905" alt="qq_37924905" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/qq_37924905"><span class="name ">水巷石子</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">还是蛮不错的,引导初学者了解基本的。</span><span class="date" title="2020-12-28 17:13:51">昨天</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14383188"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span>1</span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14400980" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">感谢支持</span><span class="date" title="2020-12-29 20:02:54">14小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14400980"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14404176" data-replyname="qq_41389354"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_41389354"><img src="https://profile.csdnimg.cn/0/9/C/3_qq_41389354" username="qq_41389354" alt="qq_41389354" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">爱码士<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="爱码士"></a><a target="_blank" href="https://blog.csdn.net/qq_41389354"><span class="name ">Java劝退师、</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">代码之路任重道远,愿跟博主努力习之。 最近我也在学习写博客,有空来看看我呀,一起互相学习。期待你的关注与支持</span><span class="date" title="2020-12-30 05:59:24">4小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14404176"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li></ul><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14398764" data-replyname="weixin_53535262"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/weixin_53535262"><img src="https://profile.csdnimg.cn/E/E/9/3_weixin_53535262" username="weixin_53535262" alt="weixin_53535262" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码农<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码农"></a><a target="_blank" href="https://blog.csdn.net/weixin_53535262"><span class="name ">weixin_53535262</span></a><span class="colon">:</span><span class="floor-num"></span><span class="new-comment">大佬,那个switch (oper)为什么一直报错</span><span class="date" title="2020-12-29 17:08:51">17小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14398764"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li><li class="replay-box" style="display:block"><ul class="comment-list"><li class="comment-line-box d-flex" data-commentid="14404454" data-replyname="weixin_53535262"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/weixin_53535262"><img src="https://profile.csdnimg.cn/E/E/9/3_weixin_53535262" username="weixin_53535262" alt="weixin_53535262" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码农<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码农"></a><a target="_blank" href="https://blog.csdn.net/weixin_53535262"><span class="name mr-8">weixin_53535262</span></a><span class="text">回复</span><a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><span class="nick-name">程序猿啊哈</span><span class="colon">:</span><span class="text"></span><span class="new-comment">加了</span><span class="date" title="2020-12-30 08:18:18">2小时前</span><span class="new-opt-floating"><a class="btn-bt  btn-reply" data-type="reply" data-flag="true">回复</a><a class="btn-bt  btn-report"><img class="btn-report-img" src="https://i-blog.csdnimg.cn/blog_migrate/2576ca68948267d5b525986c74c70556.png" title=""><span data-type="report" class="hide-report">举报</span></a></span></div><div class="comment-like " data-commentid="14404454"><img class="comment-like-img unclickImg" src="https://i-blog.csdnimg.cn/blog_migrate/279b096a482502ae545b68c791c9e31e.png" title="点赞"><img class="comment-like-img comment-like-img-hover" style="display:none" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><img class="comment-like-img clickedImg" src="https://i-blog.csdnimg.cn/blog_migrate/164559133c2a4b688adb616df20d63f7.png" title="点赞"><span></span></div></div></div></li><li class="comment-line-box d-flex" data-commentid="14403735" data-replyname="qq_49529322"><div style="display: flex;width: 100%;">      <a target="_blank" href="https://blog.csdn.net/qq_49529322"><img src="https://profile.csdnimg.cn/A/8/3/3_qq_49529322" username="qq_49529322" alt="qq_49529322" class="avatar"></a>        <div class="right-box ">          <div class="new-info-box clearfix">            <a class="comment-tag" target="_blank" href="https://blog.csdn.net/blogdevteam/article/details/103478461">码工<img class="comment-tag-img" src="https://i-blog.csdnimg.cn/blog_migrate/44997a42cc44fb7dc913a7381e76a305.png" title="码工"></a><a target="_blank" href="https://blog.csdn.net/qq_49529322"><span class="name mr-8">程序猿啊哈<img class="is_bloger" src="https://i-blog.csdnimg.cn/blog_migrate/ad96fba88ebbbad89ad942562bc02cfb.png"></span></a><span class="text">回复</span><span class="colon">:</span><span class="text"></span><span class="new-comment">加我QQ   2562777581

明天我给你远程操作一下9小时前回复举报

### 回答1: 可以使用Python中的pandas库将时间序列数据存储到DataFrame中,然后使用pandas的to_excel()方法将其输出到Excel文件中。 首先,需要使用pandas中的date_range()函数生成时间索引,确定时间范围从2018-01-01 08:00:00到2020-12-30 00:00:00,每小时取一个值。 其次,使用pandas中的DataFrame()函数创建一个新的DataFrame并将时间索引设置为刚才生成的时间索引。 最后,使用DataFrame的to_excel()方法将其输出到Excel文件中。 代码示例如下: ``` python import pandas as pd # 生成时间索引 time_index = pd.date_range('2018-01-01 08:00:00', '2020-12-30 00:00:00', freq='H') # 创建新的DataFrame并将时间索引设置为刚才生成的时间索引 df = pd.DataFrame(index=time_index) # 输出到Excel文件 df.to_excel('output.xlsx') ``` ### 回答2: 首先,我们需要计算从2018年1月1日08:00:00到20201230日00:00:00的总小时数。我们可以使用日期时间函数来完成这个计算。 首先,计算起始日期和结束日期之间的总天数。起始日期是2018年1月1日08:00:00,结束日期是20201230日00:00:00。计算这两个日期之间的天数,可以使用以下公式: =end_date - start_date + 1 其中,"+1"是因为起始日期所占的一天也要计算在内。 接下来,计算总小时数。因为每天有24小时,所以总小时数等于总天数乘以24。公式如下: total_hours = total_days * 24 现在我们知道了从起始日期到结束日期的总小时数,我们可以使用循环来逐小时生成日期时间,并将其写入Excel文件。我们可以使用Python中的openpyxl库来实现这个功能。 首先,导入必要的库: import openpyxl from datetime import datetime, timedelta 然后,创建一个新的Excel工作簿: workbook = openpyxl.Workbook() sheet = workbook.active 接下来,设置起始日期和结束日期: start_date = datetime(2018, 1, 1, 8, 0, 0) end_date = datetime(2020, 12, 30, 0, 0, 0) 然后,用循环生成连续的日期时间,并将其写入Excel文件: current_date = start_date for i in range(total_hours): sheet.cell(row=i+1, column=1).value = current_date current_date += timedelta(hours=1) 最后,保存Excel文件: workbook.save('output.xlsx') 以上就是将2018年1月1日08:00:00到20201230日00:00:00的连续时间每小时取一个值,并输出为Excel文件的步骤。 ### 回答3: 要将2018-01-01 08:00:00到2020-12-30 00:00:00这个时间范围内每小时连续取一个值,并输出到Excel文件中,可以使用Python编程语言中的pandas和openpyxl库来实现。 首先,我们需要导入所需的库: ```python import pandas as pd from openpyxl import Workbook ``` 接下来,我们可以创建一个日期范围,从2018-01-01 08:00:00到2020-12-30 00:00:00,每小时的频率,并将其存储在一个DataFrame中: ```python start_date = pd.Timestamp('2018-01-01 08:00:00') end_date = pd.Timestamp('2020-12-30 00:00:00') date_range = pd.date_range(start=start_date, end=end_date, freq='1H') df = pd.DataFrame(date_range, columns=['Timestamp']) ``` 然后,我们可以向DataFrame中添加其他需要的列,例如年、月、日和小时: ```python df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df['Day'] = df['Timestamp'].dt.day df['Hour'] = df['Timestamp'].dt.hour ``` 最后,我们可以使用openpyxl库将DataFrame保存到Excel文件中: ```python output_file = 'output.xlsx' with pd.ExcelWriter(output_file, engine='openpyxl') as writer: df.to_excel(writer, index=False) ``` 完整的代码如下: ```python import pandas as pd from openpyxl import Workbook start_date = pd.Timestamp('2018-01-01 08:00:00') end_date = pd.Timestamp('2020-12-30 00:00:00') date_range = pd.date_range(start=start_date, end=end_date, freq='1H') df = pd.DataFrame(date_range, columns=['Timestamp']) df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df['Day'] = df['Timestamp'].dt.day df['Hour'] = df['Timestamp'].dt.hour output_file = 'output.xlsx' with pd.ExcelWriter(output_file, engine='openpyxl') as writer: df.to_excel(writer, index=False) ``` 运行这段代码将生成一个名为output.xlsx的Excel文件,其中包含从2018-01-01 08:00:00到2020-12-30 00:00:00每小时连续取一个值的数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值