公告版位

沒有痛苦 就沒有收穫
若內容對你有幫助,可以留言讓我知道哦~
有問題想要諮詢可以請至這裡連絡我哦 =>不會就放這邊

 


目前分類:Python (10)

瀏覽方式: 標題列表 簡短摘要

你可以透過Python的os模組中的path.exists()方法來檢查檔案是否存在。如果檔案存在,可以使用datetime模組來生成一個新的檔案名稱。以下是示範程式碼

import os
from datetime import datetime

JL8051 發表在 痞客邦 留言(0) 人氣()

hex_list = [f"{i:X}" for i in range(16)]
print(hex_list)


JL8051 發表在 痞客邦 留言(0) 人氣()

Python use

strhex = "0x01"
int(strhex,16)

JL8051 發表在 痞客邦 留言(0) 人氣()

時間相減範例程式

start_dt = datetime.datetime.strptime(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), '%Y-%m-%d %H:%M:%S')

end_dt = datetime.datetime.strptime(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), '%Y-%m-%d %H:%M:%S')

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

每次都遇到 local variable referenced before assignment 錯誤的解決方案 這個問題

主要是變數需要變成全域變數才可以使用

可以參考這篇 : https://www.delftstack.com/zh-tw/howto/python/python-local-variable-referenced-before-assignment/

JL8051 發表在 痞客邦 留言(0) 人氣()

進入pyhton

>>> int("0x12F", base=16)
303

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

python太多語法,放這邊練習


filedialog 對話框函數測試

import tkinter as tk

JL8051 發表在 痞客邦 留言(0) 人氣()

更新: 原來是我read回來最後一個字串帶有換行

所以當我在寫入時,就會有多一個換行的\n寫入

如果在python 執行open

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

使用python 上傳資料到google excel上

https://sites.google.com/site/zsgititit/home/python-cheng-shi-she-ji/shi-yongpython-shang-chuan-zi-liao-daogoogle-shi-suan-biao

https://blog.cavedu.com/2020/03/09/app-inventor-google/

文章標籤

JL8051 發表在 痞客邦 留言(1) 人氣()

錯誤:UnboundLocalError: local variable 'aww' referenced before assignment

原因 : 變數沒有設定global

 

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()