Python TQC考題306 迴圈階乘計算 by 儲蓄保險王 · 2022-04-28 #Python TQC考題306 迴圈階乘計算 n=eval(input()) ans=1 for i in range(1,n+1): #記得從1開始 ans=ans*i print(ans) 相關文章Python: 使用 pandas 將長格式數據轉換為寬格式(樞紐分析)Python:如何繪製文字雲? from wordcloud import WordCloudPython如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.contentPython: 如何使用speech_recognition 將wav檔轉為文字?with sr.AudioFile(p) as source: audio = r.record(source) ; 如何使用mic當音源? with sr.Microphone() as source: audio_data = recognizer.listen(source)Python Logging 完全指南:從基礎到實戰應用; import logging ; logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler('app.log', mode='a', encoding='utf-8')] ) ; inspect.currentframe().f_code.co_name #動態取得funcNamePython-docx 進階手術室:從底層 XML 到超連結混合技; from docx.opc.constants import RELATIONSHIP_TYPE as RT ; part = doc.part ; r_id = part.relate_to(url, RT.HYPERLINK, is_external=True)Python 正則表示法(Regular Expression) : re.Match 物件的 .group() .groups()方法 #捕獲組Python爬蟲: selenium如何find_elements() ? 如何搭配portable Chrome? from selenium.webdriver.common.by import By ; from selenium.webdriver.chrome.options import Options ; option = Options() ; option.binary_location = chrome_portable_pathPython: list.index() 只能找到第一個元素的index,若元素有重複,如何找出所有index? indexes = [index for index, value in enumerate(my_list) if value == target]
0 Python: 如何判斷字符串內容是否為數字(整數或浮點數)? isinstance( eval( entry.get() ), (float, int) ) ; str.isdigit() #不包括小數點和負號 ; try~ except ValueError~ ; 正則表示法 regular expression ; pattern = ‘^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$’ 2023-05-11
0 python Graphviz中控制子圖(子圖可以僅含一個node)垂直位置教學: rank=’sink’ ; rank=’source’ ; rank=’same’ ; 為子圖的屬性,在node中設定無效 ; 不可與g.attr(newrank=’true’) #子圖同高度 一起使用; with g.subgraph() as s: s.attr(rank=’sink’) # 設置子圖為sink ; s.node(‘Logo’, ‘Company Logo’) 2025-03-17
近期留言