發表文章

目前顯示的是 3月, 2024的文章

謝庭維python檔案方法utf8

  f = open("ascii.txt", "r+", encoding='utf8') x = f.read() print(x) f.write("\n劉任昌") #寫入字串 f.close() #劉任昌關閉檔案r+讀增加append print('f長度',len(x)) for i in x: #用迴圈印出每一個字元 print(i)

謝庭維python內建built-in函數functions字串string方法methods迴圈Loop

圖片
截圖   w3schools內建函數列表 Function Description abs() Returns the absolute value of a number all() 都是真的Returns True if all items in an iterable object are true any() Returns True if any item in an iterable object is true ascii() Returns a readable version of an object. Replaces none-ascii characters with escape character bin() 二進位數Returns the binary version of a number bool() Returns the boolean value of the specified object bytearray() Returns an array of bytes bytes() Returns a bytes object callable() Returns True if the specified object is callable, otherwise False chr() Returns a character字元 from the specified Unicode code. classmethod() Converts a method into a class method compile() Returns the specified source as an object, ready to be executed complex() Returns a complex number delattr() Deletes the specified attribute (property or method) from the specified object dict() Returns a dictionary (Array) dir() Returns a list of the specified object's properties and methods divmod()...