1. 程式人生 > >python基礎(set)補充

python基礎(set)補充

class file(object)
    def close(self): # real signature unknown; restored from __doc__
        關閉檔案
        """
        close() -> None or (perhaps) an integer.  Close the file.
         
        Sets data attribute .closed to True.  A closed file cannot be used for
        further I/O operations.  close() may be called more than once without
        error.  Some kinds of file objects (for example, opened by popen())
        may return an exit status upon closing.
        """
 
    def fileno(self): # real signature unknown; restored from __doc__
        檔案描述符  
         """
        fileno() -> integer "file descriptor".
         
        This is needed for lower-level file interfaces, such os.read().
        """
        return 0    
 
    def flush(self): # real signature unknown; restored from __doc__
        重新整理檔案內部緩衝區
        """ flush() -> None.  Flush the internal I/O buffer. """
        pass
 
 
    def isatty(self): # real signature unknown; restored from __doc__
        判斷檔案是否是同意tty裝置
        """ isatty() -> true or false.  True if the file is connected to a tty device. """
        return False
 
 
    def next(self): # real signature unknown; restored from __doc__
        獲取下一行資料,不存在,則報錯
        """ x.next() -> the next value, or raise StopIteration """
        pass
 
    def read(self, size=None): # real signature unknown; restored from __doc__
        讀取指定位元組資料
        """
        read([size]) -> read at most size bytes, returned as a string.
         
        If the size argument is negative or omitted, read until EOF is reached.
        Notice that when in non-blocking mode, less data than what was requested
        may be returned, even if no size parameter was given.
        """
        pass
 
    def readinto(self): # real signature unknown; restored from __doc__
        讀取到緩衝區,不要用,將被遺棄
        """ readinto() -> Undocumented.  Don't use this; it may go away. """
        pass
 
    def readline(self, size=None): # real signature unknown; restored from __doc__
        僅讀取一行資料
        """
        readline([size]) -> next line from the file, as a string.
         
        Retain newline.  A non-negative size argument limits the maximum
        number of bytes to return (an incomplete line may be returned then).
        Return an empty string at EOF.
        """
        pass
 
    def readlines(self, size=None): # real signature unknown; restored from __doc__
        讀取所有資料,並根據換行儲存值列表
        """
        readlines([size]) -> list of strings, each a line from the file.
         
        Call readline() repeatedly and return a list of the lines so read.
        The optional size argument, if given, is an approximate bound on the
        total number of bytes in the lines returned.
        """
        return []
 
    def seek(self, offset, whence=None): # real signature unknown; restored from __doc__
        指定檔案中指標位置
        """
        seek(offset[, whence]) -> None.  Move to new file position.
         
        Argument offset is a byte count.  Optional argument whence defaults to
(offset from start of file, offset should be >= 0); other values are 1
        (move relative to current position, positive or negative), and 2 (move
        relative to end of file, usually negative, although many platforms allow
        seeking beyond the end of a file).  If the file is opened in text mode,
        only offsets returned by tell() are legal.  Use of other offsets causes
        undefined behavior.
        Note that not all file objects are seekable.
        """
        pass
 
    def tell(self): # real signature unknown; restored from __doc__
        獲取當前指標位置
        """ tell() -> current file position, an integer (may be a long integer). """
        pass
 
    def truncate(self, size=None): # real signature unknown; restored from __doc__
        截斷資料,僅保留指定之前資料
        """
        truncate([size]) -> None.  Truncate the file to at most size bytes.
         
        Size defaults to the current file position, as returned by tell().
        """
        pass
 
    def write(self, p_str): # real signature unknown; restored from __doc__
        寫內容
        """
        write(str) -> None.  Write string str to file.
         
        Note that due to buffering, flush() or close() may be needed before
        the file on disk reflects the data written.
        """
        pass
 
    def writelines(self, sequence_of_strings): # real signature unknown; restored from __doc__
        將一個字串列表寫入檔案
        """
        writelines(sequence_of_strings) -> None.  Write the strings to the file.
         
        Note that newlines are not added.  The sequence can be any iterable object
        producing strings. This is equivalent to calling write() for each string.
        """
        pass
 
    def xreadlines(self): # real signature unknown; restored from __doc__
        可用於逐行讀取檔案,非全部
        """
        xreadlines() -> returns self.
         
        For backward compatibility. File objects now include the performance
        optimizations previously implemented in the xreadlines module.
        """
        pass

相關推薦

python基礎set補充

class file(object) def close(self): # real signature unknown; restored from __doc__ 關閉檔案 """ close() -> None or (perhaps) a

python基礎7:元祖類型賦值補充

pre 定義 index orm python 報錯 {} 兩個 子字符串 前面學了列表和字典,今天我們看一個和列表相似的類型元祖。 預習: 簡單購物車   實現打印商品詳細信息,用戶輸入商品名和購買個數,則將商品名,價格,購買個數加入購物列表,如果輸入為空或其他非法輸入則

python基礎6---set、collections介紹

iss ini format eof init dir turn alt __init__ 1.set(集合)   set和dict類似,也是一組key的集合,但不存儲value。由於key不能重復,所以,在set中,沒有重復的key。   集合和我們數學中集合的概念是一樣

Python基礎set 集合

全部測試程式碼 #!/usr/bin/env python3 #_*_ conding:utf-8 _*_ #set是一組key的集合,但是沒有重複的key,重複的值自動被過濾 # 建立一個set,以list作為輸入集合,輸出的資料用大括號{}顯示,且是無序的 s=set([1

python基礎----字符編碼以及文件處理

odin mod window 存儲空間 表示 一行 內存數據 rec 錯誤 字符編碼與文件處理 一.字符編碼 由字符翻譯成二進制數字的過程 字符--------(翻譯過程)------->數字 這個過程實際就是一個字符如何對應一個特定數字的標準,這個標準

Python基礎6_函數

傳遞 獲得 不執行 分配 參數 code else turn 依賴 一 為何要有函數? 不加區分地將所有功能的代碼壘到一起,問題是:   代碼可讀性差   代碼冗余   代碼可擴展差 如何解決?  函數即工具,事先準備工具的過程是定義函數,拿來就用指的就是函數調

Python基礎11_python模塊之time模塊、rando模塊、hashlib、os模塊

路徑 固定 val 登錄密碼 rand getcwd ges ble sun 一、模塊 1、什麽是模塊:一個模塊就是一個包含了python定義和聲明的文件,文件名就是模塊名字加上.py的後綴   模塊的本質:模塊的本質是一個py文件 2、模塊分為三類:1)內置模塊;2)第三

Python基礎10分解質因數

pen [] 基礎 app 分解質因數 pytho 分解 bsp python import mathsu=[]for i in range(100,1000): a=i/100 b=(i-100*a)/10 #b=i/10%10 c=i-100

Python基礎13_python模塊之re模塊(正則表達式)

取反 clas 執行 true dha blog strong 邊界 .com 8、re模塊:正則表達式   就其本質而言,正則表達式(或 RE)是一種小型的、高度專業化的編程語言,(在Python中)它內嵌在Python中,並通過 re 模塊實現。正則表達式模式被編譯

Python基礎16_面向對象程序設計類、繼承、派生、組合、接口

特征 abc 有效 相同 現實 父類 student 需求 ict 一、面向過程程序設計與面向對象程序設計 面向過程的程序設計:核心是過程,過程就解決問題的步驟,基於該思想設計程序就像是在設計一條流水線,是一種機械式的思維方式 優點:復雜的問題的簡單化,流程化

Python基礎19_異常處理

poi 錯誤處理 turn 清晰 system 由於 對象 編譯 sharp 一、異常處理 錯誤和異常: 1、錯誤的種類:   1)語法錯誤:這種錯誤,根本過不了python解釋器的語法檢測,必須在程序執行前就改正   2)邏輯錯誤:       例如: res1=1/0

python基礎3:輸入輸出與運算符

http 占位符 str png blog 方法 image 16px 提示 今天總結一下最基礎的輸入輸出和運算符 輸入: python3裏都是input("") input() name = input() #輸入的值會直接賦值給name name = i

python基礎4:條件語句與循環語句

語句 單分支 繼續 目的 輸入 代碼 原則 src 分享 今天我們看看條件語句與循環語句。 預習: 1、使用while循環輸出1 2 3 4 5 6 8 9 10 2、求1-100的所有數的和 3、輸出 1-100 內的所有奇數 4、輸出 1-100 內的所有偶數 5、求1

python基礎5:數字和字符串類型

digi 數字 身高 isalnum 下標 spl 大小寫 () ljust 今天總結一下數據類型中的數字和字符串型。 預習: # 寫代碼,有如下變量,請按照要求實現每個功能 (共6分,每小題各0.5分) name = " aleX" # 1) 移除 name 變

Python基礎

類型 spa 例子 hat except 存在 內容 限制 字符數 Python基礎1 1.Hello World程序 2.變量 3.用戶輸入 4.模塊初識 5.數據類型初識 6.數據運算 7.表達式if ...else語句 8.表達式fo

Python基礎9三元表達式、列表解析、生成器表達式

直接 bsp cut port end 雞蛋 /var/ .cn xorg 一、三元表達式 三元運算,是對簡單的條件語句的縮寫。 # if條件語句 if x > f: print(x) else: print(y)    # 條件成

Python基礎1:基本運算符

src com .com strong images http es2017 image 1-1 1. 算數運算: 2. 比較運算 3. 賦值運算 4. 邏輯運算 5. 成員運算 Python基礎(1):基本運算符

Python基礎7:基本數據類型dict

sel open name sta allow zed items 格式 鍵值對 字典(dict):   說明:字典是另一種可變容器模型,且可存儲任意類型對象。字典的每個鍵值(key=>value)對用冒號(:)分割,每個對之間用逗號(,)分割,整個字典包括在花括號{

Python集合set類型的操作

包含 感覺 關系 lis 註意 所有 rem 錯誤 通過 python的set和其他語言類似, 是一個無序不重復元素集, 基本功能包括關系測試和消除重復元素. 集合對象還支持union(聯合), intersection(交), difference(差)和sysmmetr

python基礎1

pythonpython是可執行程序,必須聲明解釋器1.python腳本解釋器指定的兩種方法:#!/usr/bin/env python 查找環境變量下的py文件#!//usr/bin/python 查找bin目錄下的py文件2.什麽是UTF-8?UTF-8是世界通用的語言編碼,在程序的首行加上