首頁 > 運維 > linux運維 > Python自動化開發學習的第一週作業---三級選單

Python自動化開發學習的第一週作業---三級選單

PHP中文网
發布: 2017-07-13 18:16:19
原創
1669 人瀏覽過

作業需求:
(1)執行程式輸出第一層選單
(2)選擇一級選單某項,輸出二級選單,同理輸出三級選單
(3)讓使用者選擇是否要退出
(4)有返回上一層選單的功能

##
<span style="color: #008080">  1</span> data =<span style="color: #000000"> {
</span><span style="color: #008080">  2</span>     <span style="color: #800000">"</span><span style="color: #800000">天津</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080">  3</span>         <span style="color: #800000">"</span><span style="color: #800000">南开区</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080">  4</span>             <span style="color: #800000">"</span><span style="color: #800000">南开大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080">  5</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080">  6</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080">  7</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080">  8</span> <span style="color: #000000">            },
</span><span style="color: #008080">  9</span>             <span style="color: #800000">"</span><span style="color: #800000">科技大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 10</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 11</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 12</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 13</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 14</span>             <span style="color: #800000">"</span><span style="color: #800000">理工大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 15</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 16</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 17</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 18</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 19</span> <span style="color: #000000">        },
</span><span style="color: #008080"> 20</span>         <span style="color: #800000">"</span><span style="color: #800000">武清区</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 21</span>             <span style="color: #800000">"</span><span style="color: #800000">武清大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 22</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 23</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 24</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 25</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 26</span>             <span style="color: #800000">"</span><span style="color: #800000">武清科技大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 27</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 28</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 29</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 30</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 31</span>             <span style="color: #800000">"</span><span style="color: #800000">武清理工大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 32</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 33</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 34</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 35</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 36</span> <span style="color: #000000">        },
</span><span style="color: #008080"> 37</span>         <span style="color: #800000">"</span><span style="color: #800000">北辰区</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 38</span>             <span style="color: #800000">"</span><span style="color: #800000">北辰大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 39</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 40</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 41</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 42</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 43</span>             <span style="color: #800000">"</span><span style="color: #800000">北辰科技大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 44</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 45</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 46</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 47</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 48</span>             <span style="color: #800000">"</span><span style="color: #800000">北辰理工大学</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 49</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 50</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 51</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">:{},
</span><span style="color: #008080"> 52</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 53</span> <span style="color: #000000">        },
</span><span style="color: #008080"> 54</span> <span style="color: #000000">    },
</span><span style="color: #008080"> 55</span>     <span style="color: #800000">"</span><span style="color: #800000">河北</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080"> 56</span>         <span style="color: #800000">"</span><span style="color: #800000">保定市</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 57</span>             <span style="color: #800000">"</span><span style="color: #800000">保定大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 58</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 59</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 60</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 61</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 62</span>             <span style="color: #800000">"</span><span style="color: #800000">保定科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 63</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 64</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 65</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 66</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 67</span>             <span style="color: #800000">"</span><span style="color: #800000">保定理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 68</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 69</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 70</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 71</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 72</span> <span style="color: #000000">        },
</span><span style="color: #008080"> 73</span>         <span style="color: #800000">"</span><span style="color: #800000">秦皇岛</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 74</span>             <span style="color: #800000">"</span><span style="color: #800000">秦皇岛大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 75</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 76</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 77</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 78</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 79</span>             <span style="color: #800000">"</span><span style="color: #800000">秦皇岛科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 80</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 81</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 82</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 83</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 84</span>             <span style="color: #800000">"</span><span style="color: #800000">秦皇岛理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 85</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 86</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 87</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 88</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 89</span> <span style="color: #000000">        },
</span><span style="color: #008080"> 90</span>         <span style="color: #800000">"</span><span style="color: #800000">石家庄</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 91</span>             <span style="color: #800000">"</span><span style="color: #800000">石家庄大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 92</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 93</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 94</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 95</span> <span style="color: #000000">            },
</span><span style="color: #008080"> 96</span>             <span style="color: #800000">"</span><span style="color: #800000">石家庄科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080"> 97</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 98</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080"> 99</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">100</span> <span style="color: #000000">            },
</span><span style="color: #008080">101</span>             <span style="color: #800000">"</span><span style="color: #800000">石家庄理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">102</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">103</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">104</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">105</span> <span style="color: #000000">            },
</span><span style="color: #008080">106</span> <span style="color: #000000">        },
</span><span style="color: #008080">107</span> <span style="color: #000000">    },
</span><span style="color: #008080">108</span>     <span style="color: #800000">"</span><span style="color: #800000">河南</span><span style="color: #800000">"</span><span style="color: #000000">:{
</span><span style="color: #008080">109</span>         <span style="color: #800000">"</span><span style="color: #800000">郑州市</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">110</span>             <span style="color: #800000">"</span><span style="color: #800000">郑州大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">111</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">112</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">113</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">114</span> <span style="color: #000000">            },
</span><span style="color: #008080">115</span>             <span style="color: #800000">"</span><span style="color: #800000">郑州科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">116</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">117</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">118</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">119</span> <span style="color: #000000">            },
</span><span style="color: #008080">120</span>             <span style="color: #800000">"</span><span style="color: #800000">郑州理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">121</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">122</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">123</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">124</span> <span style="color: #000000">            },
</span><span style="color: #008080">125</span> <span style="color: #000000">        },
</span><span style="color: #008080">126</span>         <span style="color: #800000">"</span><span style="color: #800000">南阳市</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">127</span>             <span style="color: #800000">"</span><span style="color: #800000">南阳大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">128</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">129</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">130</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">131</span> <span style="color: #000000">            },
</span><span style="color: #008080">132</span>             <span style="color: #800000">"</span><span style="color: #800000">南阳科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">133</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">134</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">135</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">136</span> <span style="color: #000000">            },
</span><span style="color: #008080">137</span>             <span style="color: #800000">"</span><span style="color: #800000">南阳理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">138</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">139</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">140</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">141</span> <span style="color: #000000">            },
</span><span style="color: #008080">142</span> <span style="color: #000000">        },
</span><span style="color: #008080">143</span>         <span style="color: #800000">"</span><span style="color: #800000">登封市</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">144</span>             <span style="color: #800000">"</span><span style="color: #800000">登封大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">145</span>                 <span style="color: #800000">"</span><span style="color: #800000">历史系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">146</span>                 <span style="color: #800000">"</span><span style="color: #800000">文学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">147</span>                 <span style="color: #800000">"</span><span style="color: #800000">英语系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">148</span> <span style="color: #000000">            },
</span><span style="color: #008080">149</span>             <span style="color: #800000">"</span><span style="color: #800000">登封科技大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">150</span>                 <span style="color: #800000">"</span><span style="color: #800000">计算机系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">151</span>                 <span style="color: #800000">"</span><span style="color: #800000">机器系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">152</span>                 <span style="color: #800000">"</span><span style="color: #800000">软件系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">153</span> <span style="color: #000000">            },
</span><span style="color: #008080">154</span>             <span style="color: #800000">"</span><span style="color: #800000">登封理工大学</span><span style="color: #800000">"</span><span style="color: #000000">: {
</span><span style="color: #008080">155</span>                 <span style="color: #800000">"</span><span style="color: #800000">数学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">156</span>                 <span style="color: #800000">"</span><span style="color: #800000">化学系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">157</span>                 <span style="color: #800000">"</span><span style="color: #800000">物理系</span><span style="color: #800000">"</span><span style="color: #000000">: {},
</span><span style="color: #008080">158</span> <span style="color: #000000">            },
</span><span style="color: #008080">159</span> <span style="color: #000000">        },
</span><span style="color: #008080">160</span> <span style="color: #000000">    },
</span><span style="color: #008080">161</span> <span style="color: #000000">}
</span><span style="color: #008080">162</span> <span style="color: #008000">#</span><span style="color: #008000">exit_flag = False</span>
<span style="color: #008080">163</span> <span style="color: #0000ff">while</span><span style="color: #000000"> True:
</span><span style="color: #008080">164</span>     <span style="color: #0000ff">for</span> i <span style="color: #0000ff">in</span><span style="color: #000000"> data :
</span><span style="color: #008080">165</span>         <span style="color: #0000ff">print</span><span style="color: #000000"> (i)
</span><span style="color: #008080">166</span>     choice = input (<span style="color: #800000">"</span><span style="color: #800000">input:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">167</span>     <span style="color: #0000ff">if</span> choice <span style="color: #0000ff">in</span><span style="color: #000000"> data:
</span><span style="color: #008080">168</span>         <span style="color: #0000ff">while</span><span style="color: #000000"> True:
</span><span style="color: #008080">169</span>             <span style="color: #0000ff">for</span> i2 <span style="color: #0000ff">in</span><span style="color: #000000"> data[choice]:
</span><span style="color: #008080">170</span>                 <span style="color: #0000ff">print</span><span style="color: #000000"> (i2)
</span><span style="color: #008080">171</span>             choice2 = input(<span style="color: #800000">"</span><span style="color: #800000">input2:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">172</span>             <span style="color: #0000ff">if</span> choice2 <span style="color: #0000ff">in</span><span style="color: #000000"> data[choice]:
</span><span style="color: #008080">173</span>                 <span style="color: #0000ff">while</span><span style="color: #000000"> True:
</span><span style="color: #008080">174</span>                     <span style="color: #0000ff">for</span> i3 <span style="color: #0000ff">in</span><span style="color: #000000"> data[choice][choice2]:
</span><span style="color: #008080">175</span>                         <span style="color: #0000ff">print</span><span style="color: #000000"> (i3)
</span><span style="color: #008080">176</span>                     choice3 = input(<span style="color: #800000">"</span><span style="color: #800000">input3:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">177</span>                     <span style="color: #0000ff">if</span> choice3 <span style="color: #0000ff">in</span><span style="color: #000000"> data[choice][choice2]:
</span><span style="color: #008080">178</span>                         <span style="color: #0000ff">for</span> i4 <span style="color: #0000ff">in</span><span style="color: #000000"> data[choice][choice2][choice3]:
</span><span style="color: #008080">179</span>                             <span style="color: #0000ff">print</span><span style="color: #000000">(i4)
</span><span style="color: #008080">180</span>                         choice4 = input(<span style="color: #800000">"</span><span style="color: #800000">Press b to return to the previous level:</span><span style="color: #800000">"</span><span style="color: #000000">)
</span><span style="color: #008080">181</span>                         <span style="color: #0000ff">if</span> choice4 == <span style="color: #800000">"</span><span style="color: #800000">b</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">182</span>                             <span style="color: #0000ff">pass</span>
<span style="color: #008080">183</span>                         <span style="color: #0000ff">elif</span> choice4 == <span style="color: #800000">"</span><span style="color: #800000">q</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">184</span> <span style="color: #000000">                            exit ()
</span><span style="color: #008080">185</span>                     <span style="color: #0000ff">if</span> choice3 == <span style="color: #800000">"</span><span style="color: #800000">b</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">186</span>                         <span style="color: #0000ff">break</span>
<span style="color: #008080">187</span>                     <span style="color: #0000ff">elif</span> choice3 == <span style="color: #800000">"</span><span style="color: #800000">q</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">188</span> <span style="color: #000000">                        exit()
</span><span style="color: #008080">189</span>             <span style="color: #0000ff">if</span> choice2 == <span style="color: #800000">"</span><span style="color: #800000">b</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">190</span>                 <span style="color: #0000ff">break</span>
<span style="color: #008080">191</span>             <span style="color: #0000ff">elif</span> choice2 == <span style="color: #800000">"</span><span style="color: #800000">q</span><span style="color: #800000">"</span><span style="color: #000000">:
</span><span style="color: #008080">192</span>                 exit()
登入後複製
View Code

 

以上是Python自動化開發學習的第一週作業---三級選單的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板