<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                *** ## 基礎模塊 python基礎模塊包含了python基本的功能語言:邏輯、循環、數學、文本、列表、字典、顏色、變量、函數等,這些模塊是雖然簡單,但是在python編程中必不可少。 [TOC] *** ## 邏輯模塊 ### **如果 執行(if)** >![](https://img.kancloud.cn/e2/1b/e21b94f79386e2c80508be72690fa155_178x132.png) 對應python 的`if condition:`,點擊![](https://img.kancloud.cn/53/d0/53d0b5088329dc0383b2903fd98ef5b6_37x34.png)增加`elif` 和`else` 模塊。 >![](https://img.kancloud.cn/81/bf/81bf34b01480a7a8653526816900947d_331x298.png) 帶返回值的if模塊: >![](https://img.kancloud.cn/9f/52/9f5242d8c4a1e1aeea1112d57b795c81_138x112.png) ### **比較運算** 點擊小三角切換運算符,所有比較運算符返回1表示真,返回0表示假。這分別與特殊的變量True和False等價。注意,這些變量名的大寫。 | 模塊 | 運算符 | 描述 | 實例 | | --- | --- | --- | --- | | ![](https://img.kancloud.cn/4e/84/4e840c103a879e190a0dfeb06c6f6324_213x67.png)| \== | 等于 - 比較對象是否相等 | (a == b) 返回 False。 | |![](https://img.kancloud.cn/4f/71/4f71f7ae9d7046590761c5c632130989_165x52.png) | != | 不等于 - 比較兩個對象是否不相等 | (a != b) 返回 True。 | | ![](https://img.kancloud.cn/39/86/398697e2b0b141a1affa98e170454c68_166x52.png) | \> | 大于 - 返回x是否大于y | (a > b) 返回 False。 | | ![](https://img.kancloud.cn/d0/d0/d0d0f60b16e75213f3e50ee97acb4e3b_166x52.png)| < | 小于 - 返回x是否小于y。 | (a < b) 返回 True。 | | ![](https://img.kancloud.cn/71/d4/71d4c961a4a8b1399cb48b74d2018261_165x52.png) | \>= | 大于等于 - 返回x是否大于等于y。 | (a >= b) 返回 False。 | | ![](https://img.kancloud.cn/71/5d/715d5dc1a86f03328266f4003c696da2_165x52.png) | <= | 小于等于 - 返回x是否小于等于y。 | (a <= b) 返回 True。 | ### **邏輯運算** | 模塊 | 邏輯表達式 | 描述 | 實例 | | :----- | :--------- | :----------------------------------------------------------- | :---------------------- | | ![](https://img.kancloud.cn/6e/4b/6e4b1de3c8145a1938889ecf2e68d784_195x52.png) | x and y | 布爾"與" - 如果 x 為 False,x and y 返回 x 的值,否則返回 y 的計算值。 | (a and b) 返回 20。 | | ![or](https://img.kancloud.cn/b3/8d/b38db032aea0474e4f91b5ac811f1a92_174x52.png) | x or y | 布爾"或" - 如果 x 是 True,它返回 x 的值,否則它返回 y 的計算值。 | (a or b) 返回 10。 | | ![not ](https://img.kancloud.cn/46/61/46615b1b3053705b2c6570813d1bc35c_73x36.png) | not x | 布爾"非" - 如果 x 為 True,返回 False 。如果 x 為 False,它返回 True。 | not(a and b) 返回 False | ### **空** | 模塊 | 邏輯表達式 | 描述 | | :----- | :--------- | :----------------------------------------------------------- | | ![](https://img.kancloud.cn/dd/d4/ddd47b5c927d192efba8fac6b371edac_62x37.png)| NULL| 空值,一般用于清空變量,列表、字典、指針等。 *** *** ## 循環體模塊 | 模塊 | 邏輯表達式 | 描述 | | :----- | :--------- | :----------------------------------------------------------- | | ![](https://img.kancloud.cn/75/68/7568fc1a98d0869ba72c681c22afb4a6_77x33.png)| True | 返回True值; | |![](https://img.kancloud.cn/6c/99/6c998cfadb97b48dd950f3df2882c5e4_76x32.png) | False | 返回False值; | |![](https://img.kancloud.cn/73/d6/73d6fec8fc2fc3b5e2de6b68d44b9654_186x107.png) | for count in range(x): | for循環執行X次; | |![](https://img.kancloud.cn/8e/7c/8e7ca58794cbeedbe788b713a87076e1_174x58.png) | import time</b>time.sleep(x) | 延時函數,調用time庫中的sleep(函數),延時x秒; | |![](https://img.kancloud.cn/89/77/89773219513898b74056e4cc36233815_208x91.png)| while x:<br/> | while 循環,如果x為True,執行循環體,X為False,不執行循環體; | | ![](https://img.kancloud.cn/5e/f8/5ef829fcf8a43f28d9619b7eea09c521_204x82.png) | while not x | while 循環,如果x為False,執行循環體;X為True,不執行循環體; | | ![](https://img.kancloud.cn/b2/aa/b2aa70420d5cecb631941fdf746c858c_520x107.png) | for i in range(x, y, z): | for循環,i值從x開始,每次循環增加z,直到i超過z值退出循環。 | | ![](https://img.kancloud.cn/1a/26/1a2681b9f23d39b66cddc8265f53fa6b_125x41.png)| break | 退出循環體,該模塊必須用在循環體內; | |![](https://img.kancloud.cn/91/a2/91a2cb0899ae3e1532dd196da7b8ac17_193x42.png) | continue | 執行下一次循環,該模塊必須用在循環體內。 | *** ## 數學模塊 | 模塊類型 | 模塊 | 描述 | | --- | ----- | ----- | | 數字模塊 | ![](https://img.kancloud.cn/1d/5b/1d5bd0791d183bbab434b8761fbecac2_47x32.png)| 返回數字x | | 四則運算 | ![](https://img.kancloud.cn/5a/fb/5afbb5935247cea220587da5e290ce08_188x47.png) | 返回四則運算結果 | | 一元運算 | ![](https://img.kancloud.cn/ae/b4/aeb4c7958205f57078d68ffd35dc3c82_163x34.png) | 返回平方根,絕對值,相反數、對數、指數等運算結果 | | 三角函數 | ![](https://img.kancloud.cn/0a/72/0a72289396482190e59e098ce56e95d9_140x34.png) | 以度為單位 返回三角函數sin、cos、tan、asin、acos、atan的值 | | 常用無理數 | ![](https://img.kancloud.cn/78/05/7805eda3396928361c7a87485aaa1c1a_71x34.png) | 返回π,e,φ、根號二、根號二分之一等常用無理數,精確到小數后十五位。 | | 取余 | ![](https://img.kancloud.cn/f1/4d/f14dddbaa1231a5b505a952d6e79c125_196x34.png)| 返回除法余數 | | 隨機整數 | ![](https://img.kancloud.cn/38/70/3870a70d0783c500d133d7b67b3e4e7e_392x47.png) | 返回從x到y中間的隨機整數 | | 隨機小數 | ![](https://img.kancloud.cn/18/c8/18c86b9ec48f635b7419c88d1d257a5f_112x33.png)| 返回0到1之間隨機小數,精確到小數點后十六位 | | 范圍限制 |![](https://img.kancloud.cn/9e/f7/9ef7cc102f21948dab48ca18412e5fc0_351x34.png) | 返回,限制范圍內的i值 | | 約數 | ![](https://img.kancloud.cn/f1/4d/f14dddbaa1231a5b505a952d6e79c125_196x34.png) | 返回四舍五入、近似值 | | 自增 |![](https://img.kancloud.cn/6b/be/6bbef09cffc78101940ead294df1b40f_182x38.png) | 將數字型變量自增 | | 列表運算 |![](https://img.kancloud.cn/8f/e9/8fe93cc478b74f6db685935921f373f2_200x32.png) | 返回列表中數值的和、最大值、最小值、平均數、中位數、眾數、標準差或隨機取一項返回 | | 其他 | ![](https://img.kancloud.cn/d3/0e/d30e37da957a7c9018a5c7cb081d0c0c_174x47.png) | 返回一個數是否是偶數、奇數、質數、整數、正數、負數。是否能被另一個數整除| *** ## 文本模塊 | 模塊 | 邏輯表達式 | 描述 | | :----------------------------------------------------------- | :----------------------- | :------------------------------------------ | | ![](https://img.kancloud.cn/1c/2a/1c2a6ca14cd0ba271aa20f0179f42863_76x25.png)| '' | 字符串 | | ![](https://img.kancloud.cn/d0/38/d0386877626f390b6d6a4280a2c2d601_136x50.png)| '' + '' | 合并字符串 | |![](https://img.kancloud.cn/70/f5/70f5da84c2c69bccce224856d6cdb31b_236x28.png)| 項目 = str(項目) + '' | 字符串變量末尾增加字符串 | |![](https://img.kancloud.cn/72/64/7264bc3ee4d2a80b5f35a76eee2876d9_178x36.png) | len('abc') | 返回字符串長度 | |![](https://img.kancloud.cn/ef/7c/ef7cc92454bba1e0b93c44af717e033e_158x36.png)| not len('') | 若字符串為空,返回true | |![](https://img.kancloud.cn/33/e1/33e134ffb2bc40d0998f9efc6d095b93_437x36.png) | text.find('abc') + 1 | 在text變量中尋找'abc'字符串第一次出現的位置 | |![](https://img.kancloud.cn/8d/3a/8d3a8d2e5d379161b3ee07991dc8080f_326x36.png)| text[0] | 返回字符串指定位置的字符 | | ![](https://img.kancloud.cn/b2/c6/b2c627fa145f51c203ab5c83812f3dea_426x36.png) | text[3 : 9] | 返回字符串變量中指定位置的字符串 | | ![](https://img.kancloud.cn/bf/7e/bf7e79f32275f65d94f6e7465256141a_199x25.png) | 'abc'.lower() | 字符串大小寫轉換 | | ![](https://img.kancloud.cn/40/7f/407f2a9f76ab9ad6e6a74dd80ea31529_258x25.png) | 'abc'.strip() | 消除字符串空格 | | ![](https://img.kancloud.cn/ee/a0/eea07bc5b7cad56c9440b06a178ebdde_146x28.png)| print('abc', flush=True) | 打印輸出字符串 | | ![](https://img.kancloud.cn/49/1c/491cfc35a6124dc8017ce5bcd505d293_346x26.png) | text_prompt('abc') | 檢測文本是否為純文本或數字 | *** ## 列表模塊 | 模塊 | 邏輯表達式 | 描述 | | :----------------------------------------------------------- | :------------------------------- | :--------------------------------------------- | | ![](https://img.kancloud.cn/62/53/6253717a31acd5918b6a7b064d4896ca_121x24.png) | [] | 創建空列表 | | ![](https://img.kancloud.cn/4b/09/4b09ced0b8561205eb2de35b928b67e3_129x71.png) | [None, None, None] | 從給定元素創建列表 | |![](https://img.kancloud.cn/12/74/12741865ce848e111ee109827ebaa0a7_257x34.png) | [None] * 5 | 創建一個元素相同的列表 | | ![](https://img.kancloud.cn/a6/4f/a64fc4202cda9112efc397f40f9169e7_97x33.png)| len([]) | 返回列表長度 | | ![](https://img.kancloud.cn/a3/4e/a34ecd493a54d830946ca7d63a18d215_97x33.png)| not len([]) | 若列表為空,返回true | |![](https://img.kancloud.cn/e0/ad/e0ad503f86fb636986267c10b85059f1_314x35.png) | first_index(list2, []) | 從列表中找出某個值第一個或最后匹配項的索引位置 | | ![](https://img.kancloud.cn/af/1d/af1d0747ed3ce73c8e7f5f8ea28b4e9c_291x34.png)| list2[0] | 返回指定索引位置的元素 | |![](https://img.kancloud.cn/6f/24/6f248feb6352e8286cc1680ece4d922c_335x37.png) | list2[0] = None | 給列表指定索引位置賦值 | | ![](https://img.kancloud.cn/50/a7/50a771b0d72d3d808008d028e0143c23_398x34.png) | list2[3 : 9] | 截取列表 | |![](https://img.kancloud.cn/06/41/0641b421ea7c21de54e3bd2bdb6c9b9d_314x34.png)| ''.split(',') | 將字符串轉換成列表 | | ![](https://img.kancloud.cn/bf/53/bf531c3b0052afb027a0d94409e3b21c_218x24.png)| lists_sort([], "NUMERIC", False) | 將列表重新排序 | *** ## 字典模塊 | 模塊 | 邏輯表達式 | 描述 | | --- | --- | --- | |![](https://img.kancloud.cn/d9/dc/d9dc9e53d9891bcb455a72cff5fd9b32_229x121.png)| mydict= {"key":0, "key2":0, "key3":0} | 創建字典 | | ![](https://img.kancloud.cn/cd/c0/cdc095c1a4d4b4f379542ecbffceddca_207x41.png)| mydict.keys() | 以列表形式返回一個字典所有的鍵 | |![](https://img.kancloud.cn/d5/c3/d5c3aa4c6fa0d80c1fbc293bf2621334_353x40.png)| mydict\['key'\] | 返回'key'鍵對應的值 | | ![](https://img.kancloud.cn/e4/ff/e4ffbb9c85edd8d4b7e6bb0d0cb025e3_484x41.png)| mydict.get('key',0) | 返回指定鍵的值,如果值不在字典中返回默認值 | | ![](https://img.kancloud.cn/45/ae/45aeaf5cc7ca4083e99c46a62fea3b43_502x45.png)| mydict\['key'\] = 0 | 字典中添加或創建 鍵值 | |![](https://img.kancloud.cn/64/65/64655529d51e98e2c93894b34449a8ed_416x45.png) | del mydict\['key'\] | 刪除鍵值 | | ![](https://img.kancloud.cn/ea/51/ea51e4abb9b65aba2a7b843c866b9f71_454x42.png)| mydict.pop('key') | 刪除字典給定鍵 key 所對應的值,返回值為被刪除的值。 | |![](https://img.kancloud.cn/4f/c7/4fc7ed149ada20d3f5a38ccc8afcbfed_419x45.png)| mydict.setdefault('key',0) | 和get()類似, 但如果鍵不存在于字典中,將會添加鍵并將值設為默認值 | | ![](https://img.kancloud.cn/d7/61/d7615f26143d5a8a3367a157129cff16_265x45.png) | mydict.clear() | 刪除字典內所有元素 | |![](https://img.kancloud.cn/1c/6f/1c6f36a1954e815ce4b205417f3bbc8a_273x42.png)| mydict.values() | 以列表返回字典中的所有值 | |![](https://img.kancloud.cn/25/b6/25b6e903d7d97268bacaa9e57148e2c6_190x41.png)| len(mydict) | 計算字典元素個數,即鍵的總數。 | |![](https://img.kancloud.cn/28/73/28731de4ccc2875c22b2afc6e778850f_181x44.png) | del mydict | 刪除字典 | *** ## 變量模塊 定義好的整型、浮點型、文本、列表、字典變量會自動出現在變量模塊中,方便調用。也可以通過點擊“![](https://img.kancloud.cn/f0/61/f0610183de709873e5598730faf09f31_93x28.png)”來新建變量。 *** ## 函數模塊 定義好的函數自動出現在函數模塊中,方便調用。 | 模塊 | 邏輯表達式 | 描述 | | --- | --- | --- | |![](https://img.kancloud.cn/f7/86/f7868ee9a918823ee860dbd4c821c20b_219x85.png)| def fun1(): pass | 定義沒有返回值的函數 | |![](https://img.kancloud.cn/b2/57/b257587428612a34589850875b0a999f_230x107.png)| def fun2(): return | 定義帶返回值的函數 | | ![](https://img.kancloud.cn/9e/1c/9e1c6638992489532898d6e2dec52b52_216x56.png)| if False: return | 如果條件為真,則結束函數返回返回值。該模塊只能在執函數內部使用| |![](https://img.kancloud.cn/cf/e3/cfe31f9d02b99ce748887af5d1ef33ba_70x42.png)| fun1() | 調用不帶返回值的函數 | | ![](https://img.kancloud.cn/ba/20/ba20bfde8e99a1efc905c15575d5f356_81x37.png)| fun2() | 調用帶返回值的函數 |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看