str字元串常用方法

来源:http://www.cnblogs.com/gengcx/archive/2017/04/22/6750212.html
-Advertisement-
Play Games

字元串是編程中常用的類型,字元型在記憶體中是以單個形式存儲的,比如name = "alex",在記憶體中存儲的形式為["a","l","e","x"],因此我們可以使用列表的很多功能來操作字元串,因為我開始的時候一直在想為什麼字元串可以使用切片,可以有索引,開始的時候一直不明白,後來知道了Python字 ...


    字元串是編程中常用的類型,字元型在記憶體中是以單個形式存儲的,比如name = "alex",在記憶體中存儲的形式為["a","l","e","x"],因此我們可以使用列表的很多功能來操作字元串,因為我開始的時候一直在想為什麼字元串可以使用切片,可以有索引,開始的時候一直不明白,後來知道了Python字元串的存儲形式之後才明白為什麼存在這些方法。下麵我們來看看字元串類型中包含那些方法:

    在Python中有些方法下麵有註釋,這是因為這些方法使用Python自己編寫的,我們知道Python中很多是直接調用C語言中的方法,看不到的那些是C語言中的方法。

    1.capitalize(self)

    def capitalize(self): # real signature unknown; restored from __doc__
    """
    S.capitalize() -> str
        首字母大寫,只是第一個居首第一個首字母大寫
    Return a capitalized version of S, i.e. make the first character
    have upper case and the rest lower case.
    """
    return ""

    capitalize(self)是居首首字母大寫,我們知道還有一個方法title(),下麵來比較這兩個方法的不同點:

    >>> name = "alex is sb"
  >>> name.capitalize()
  'Alex is sb'
  >>> name.title()
  'Alex Is Sb'

    從上面可以看出,capitalize(self)是居首首字母大寫,其他字母不大寫;而title(self)方法是所有單詞的首字母都大寫,這個在用的時候要知道是要求那麼字母大寫。

    2.casefold(self)

    def casefold(self): # real signature unknown; restored from __doc__
    """
    S.casefold() -> str
        所有首字母小寫,等價於lower()
    Return a version of S suitable for caseless comparisons.
    """
    return ""

    casefold(self)是將大寫字母轉化為小寫,等價於lower(self),實例如下:

    >>> name = "ALEX Is SB"
  >>> name.casefold()
  'alex is sb'
  >>> name
  'ALEX Is SB'
  >>> name.lower()
  'alex is sb'

  3.center(self,width,fillchar=None)

    def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.center(width[, fillchar]) -> str
        """center(self,width,fillchar=None)是將字元串放到中間,兩邊加上任意符號,預設空格"""
    Return S centered in a string of length width. Padding is
    done using the specified fill character (default is a space)
    """
    return ""

    center(self,width,fillchar=None),美化格式,把self放到中間,指定任意長度的字元,空白處用字元填充,預設時空字元。示例如下:

    >>> name = "您好"
  >>> name.center(12)
  '     您好     '
  >>> name.center(12,"-")
  '-----您好-----'

    4.__format__(self,format_spec)

    def __format__(self, format_spec): # real signature unknown; restored from __doc__
    """
    S.__format__(format_spec) -> str
        字元串的格式化
    Return a formatted version of S as described by format_spec.
    """
    return ""

    __format__(self,format_spec)字元串進行格式化,按照我們要求的格式進行字元串格式化操作。詳細可參考(http://www.cnblogs.com/nulige/p/6115793.html)

    >>> tp1 = "My name is {0},and I am {1} years old,I am {2}"
  >>> tp1.format("Alex","18","sb")

    'My name is Alex,and I am 18 years old,I am sb'

    >>> tp2 = "I am {1} years old,my name is {2},and I am {0}."
  >>> tp2.format("sb","18","Alex")
  'I am 18 years old,my name is Alex,and I am sb.'
    這種方法也可以用在字元串的拼接上面,使用字元串的format()方法,在{}大括弧中定義索引,告訴Python把哪個值傳給索引位置。

    5.__getattribute__(self,*args,**kwargs)

    def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """

        """反射的時候用的"""
    pass

    6.__getitem__(self,*args,**kwargs)

    def __getitem__(self, *args, **kwargs): # real signature unknown
    """ Return self[key]. """

    """得到字元串低級個元素,等價於self[key]"""
    pass
 

    就是獲取字元串中第幾個位置的字元,我們知道字元串在記憶體中是以列表形式存儲的,因此可以使用索引來獲取單個字元,實例如下:

    >>> name = "Alexissb"
  >>> name.__getitem__(2)
  'e'
  >>> name[2]
  'e'
    字元串中索引是從0開始的,獲取字元串中第幾個位置的字元。

    7.__getnewargs__(self,*args,**kwargs)

    def __getnewargs__(self, *args, **kwargs): # real signature unknown

    """__getnewargs__是跟參數有關的"""
    pass

    8.__hash__(self,*args,**kwargs)

    def __hash__(self, *args, **kwargs): # real signature unknown
    """ Return hash(self). """
    pass
   

    9.__iter__(self,*args,**kwargs)

    def __iter__(self, *args, **kwargs): # real signature unknown
    """ Implement iter(self). """
    pass

    10.__len__(self,*args,**kwargs)

    def __len__(self, *args, **kwargs): # real signature unknown
    """ Return len(self). """

        """返回字元串的長度,等價與len(self)"""
    pass

    實例如下:

    >>> name = "Alexissb"
  >>> name.__len__()
  8
  >>> len(name)
  8
    11.count(self,sub,start=None,end=None)
    def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.count(sub[, start[, end]]) -> int

        返回在字元串中出現指定字元的個數,返回一個整數

    Return the number of non-overlapping occurrences of substring sub in
    string S[start:end]. Optional arguments start and end are
    interpreted as in slice notation.
    """
    return 0

    count(self,sub,start=None,end=None)是用來統計字元串中出現特定字元的個數,返回一個整數,實例如下:

    >>> name = "Alexssbbafadgcxlsdgpssl"
    >>> name.count("a")
  2
    >>> name.count("D")
  0
    統計字元串中出現指定字元的個數,當不存在的時候返回0。

    12.encode(self,encoding='utf-8',errors='strict')

    def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
    """
    S.encode(encoding='utf-8', errors='strict') -> bytes
        編碼
    Encode S using the codec registered for encoding. Default encoding
    is 'utf-8'. errors may be given to set a different error
    handling scheme. Default is 'strict' meaning that encoding errors raise
    a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
    'xmlcharrefreplace' as well as any other name registered with
    codecs.register_error that can handle UnicodeEncodeErrors.
    """
    return b""

    實例如下:

    >>> name = "李傑"
  >>> name.encode("gbk")
  b'\xc0\xee\xbd\xdc'
    將字元串轉化為"gbk"格式,機器識別的格式。

    13.endswith(self,suffix,start=None,end=None)

    def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.endswith(suffix[, start[, end]]) -> bool
        字元串是否以指定的字元結束,endswith(self,suffix,start=None,end=None)
    Return True if S ends with the specified suffix, False otherwise.
    With optional start, test S beginning at that position.
    With optional end, stop comparing S at that position.
    suffix can also be a tuple of strings to try.
    """
    return False

    endswith(self,suffix,start=None,end=None)判斷字元串以某個指定的字元結束,如果是,則返回布爾值True;否則返回False。

    >>> name = "Alexsssbdfgedlmnopqqsstabsc"
  >>> name.endswith("c")
  True
  >>> name.endswith("s",0,5)
  True
    14.expandtabs(self,tabsize=8)

    def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
    """
    S.expandtabs(tabsize=8) -> str
        將字元串中的tab鍵轉化為空格,預設時8個位置的空格,可以自己設置參數
    Return a copy of S where all tab characters are expanded using spaces.
    If tabsize is not given, a tab size of 8 characters is assumed.
    """
    return ""

    expandtabs(self,tabsize=8)將字元串中的tab(\t)將轉化為空格,預設是轉化為8個空格,可以自己設置轉化為幾個空格。示例如下:

    >>> user = "    Alex"
  >>> user.expandtabs()
  '        Alex'
  >>> user.expandtabs(2)
  '  Alex'
  >>> user.expandtabs(0)
  'Alex'
  >>> user.expandtabs(tabsize=3)
  '   Alex'
    15.find(self,sub,start=None,end=None)

    def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.find(sub[, start[, end]]) -> int
        查找指定字元在字元串中的位置,返回位置索引,如果查找不到,則返回-1(return -1 on failure)
    Return the lowest index in S where substring sub is found,
    such that sub is contained within S[start:end]. Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.
    """
    return 0

    find(self,sub,start=None,end=None)查找指定字元在字元串中的位置,如果查找不到,則返回-1(即查找字元不存在指定字元串中),示例如下:

    >>> name
  'Alexsssbdfgedlmnopqqsstabsc'
  >>> name.find("s")
  4
  >>> name.find("s",8,len(name)-1)
  20
  >>> name.find("S")
  -1
    find(self,sub,start=None,end=None)查找這個字元第一次出現的位置索引。只查找第一個位置索引,查找失敗返回-1.
    16.index(self,sub,start=None,end=None)

    def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.index(sub[, start[, end]]) -> int
       
    Like S.find() but raise ValueError when the substring is not found.
    """
    return 0

      index(self,sub,start=None,end=None)跟find()一樣是查找指定字元在字元串中的位置索引,不同的是,如果index()查找失敗,則報錯。查找不到報錯。  示例如下:

     >>> name
  'Alexsssbdfgedlmnopqqsstabsc'
  >>> name.index("s")
  4
  >>> name.index("s",8,len(name)-1)
  20
  >>> name.index("S")
  Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
  ValueError: substring not found
    上面可以看出,index()和find()是一樣的,都是返回查找字元的位置索引,但是當index()查找不到的時候會報錯。

    17.format_map(self,mapping)

    def format_map(self, mapping): # real signature unknown; restored from __doc__
    """
    S.format_map(mapping) -> str

    Return a formatted version of S, using substitutions from mapping.
    The substitutions are identified by braces ('{' and '}').
    """
    return ""

    18.isalnum(self)

    def isalnum(self): # real signature unknown; restored from __doc__
    """
    S.isalnum() -> bool
       判斷字元串中所有的字元是否都是字元數字組成
    Return True if all characters in S are alphanumeric
    and there is at least one character in S, False otherwise.
    """
    return False

    示例如下:判斷字元串中是否所有元素只有數字和字母組成,alnum是單詞alphanumeric的縮寫,字母數字
    >>> name.isalnum()
  True
  >>> nums = "2233"
  >>> nums.isalnum()
  True

    19.isalpha()

    def isalpha(self): # real signature unknown; restored from __doc__
    """
    S.isalpha() -> bool
        判斷字元串中所有的元素是否都是字母組成
    
Return True if all characters in S are alphabetic
    and there is at least one character in S, False otherwise.
    """
 
   return False

    判斷字元串所有字元是否都是字母alpha是單詞alphabetic(字母)的縮寫:  

>>> nums = "2233"
  >>> name.isalpha()
  True
  >>> nums.isalpha()
  False
    20.isdecimal(self)

    def isdecimal(self): # real signature unknown; restored from __doc__
    """
    S.isdecimal() -> bool
        如果字元串中值包含十進位的數字,則返回True;否則返回布爾值False.
    Return True if there are only decimal characters in S,
    False otherwise.
    """
    return False

    isdecimal(self)判斷字元串中是否只包含十進位的數字,如果是,則返回True;否則返回False。示例如下:

    >>> s1 = "a122"
  >>> s2 = "222"
  >>> s3 = "&b#s"
  >>> s1.isdecimal()
  False
  >>> s2.isdecimal()
  True
  >>> s3.isdecimal()
  False
    21.isdigit(self)
    def isdigit(self): # real signature unknown; restored from __doc__
    """
    S.isdigit() -> bool
        判斷字元串是否僅僅由數字組成
    Return True if all characters in S are digits
    and there is at least one character in S, False otherwise.
    """
    return False

    isdigit(self)判斷字元串中是否僅僅包含數字,即由數字組成的字元串。實例如下:

    >>> s1 = "a122"
  >>> s2 = "222"
  >>> s3 = "&b#s"

    >>> s1.isdigit()
  False
  >>> s2.isdigit()
  True
  >>> s3.isdigit()
  False
    22.isidentifier(self)

    def isidentifier(self): # real signature unknown; restored from __doc__
    """
    S.isidentifier() -> bool

    Return True if S is a valid identifier according
    to the language definition.


    Use keyword.iskeyword() to test for reserved identifiers
    such as "def" and "class".
    """
    return False

    isidentifier(self),實例如下:

    >>> s2 = "Alex"
  >>> s3 = "list"
  >>> s2.isidentifier()
  True
  >>> s3.isidentifier()
  True
  >>> s4 = "55"
  >>> s4.isidentifier()
  False
  >>> s5 = "gengcx"
  >>> s5.isidentifier()
  True

    23.islower(self)

    def islower(self): # real signature unknown; restored from __doc__
    """
    S.islower() -> bool
        判斷是否都是小寫
    Return True if all cased characters in S are lowercase and there is
    at least one cased character in S, False otherwise.
    """
    return False

    islower(self)判斷字元串是否都是小寫,

    >>> s1 = "Alex"
  >>> s2 = "23abc"
  >>> s3 = "alex"
  >>> s4 = "AlexSb&&"
  >>> s5 = "a%@"
  >>> s1.islower()
  False
  >>> s2.islower()
  True
  >>> s3.islower()
  True
  >>> s4.islower()
  False
  >>> s5.islower()
  True
    24.isnumeric(self)

    def isnumeric(self): # real signature unknown; restored from __doc__
    """
    S.isnumeric() -> bool

    Return True if there are only numeric characters in S,
    False otherwise.
    """
    return False

    isnumeric(self)判斷字元串S中是否值包含數字在裡面,如果是,返回True;否則返回False.

    >>> name = "Alex222"
  >>> nums = "234239"
  >>> num = "23se"
  >>> l1 = "2.35"
  >>> name.isnumeric()
  False
  >>> nums.isnumeric()
  True
  >>> num.isnumeric()
  False
  >>> l1.isnumeric()
  False
    25.isprintable(self)

    def isprintable(self): # real signature unknown; restored from __doc__
    """
    S.isprintable() -> bool
       判斷一個字元串是否裡面的字元都是可以列印出來的或者字元串是空的,如果是返回True;否則返回False
    Return True if all characters in S are considered
    printable in repr() or S is empty, False otherwise.
    """
    return False

    isprintable(self) 

    >>> name = "    Alex"
  >>> name.isprintable()
  False
  >>> user = "Alex"
  >>> user.isprintable()
  True

    >>> s1 = ""
    >>> s1.isprintable()
  True
    isprintable(s1)中s1是空的字元串,但是也返回True.
    26.isspace(self)

    def isspace(self): # real signature unknown; restored from __doc__
    """
    S.isspace() -> bool
        判斷字元串中是否都是空白
    Return True if all characters in S are whitespace
    and there is at least one character in S, False otherwise.
    """
    return False

    isspace(self)判斷字元串中是否都是空白,如果是返回True;否則返回False。示例如下:

    >>> s1 = "    "
  >>> s2 = "       "
  >>> s3 = "cs   "
  >>> s1.isspace()
  True
  >>> s2.isspace()
  True
  >>> s3.isspace()
  False
    27.istitle(self)

    def istitle(self): # real signature unknown; restored from __doc__
    """
    S.istitle() -> bool
        判斷字元串中所有字元是否是首字母大寫形式,如果是返回True
    Return True if S is a titlecased string and there is at least one
    character in S, i.e. upper- and titlecase characters may only
    follow uncased characters and lowercase characters only cased ones.
    Return False otherwise.
    """
    return False

    istitle(self)判斷是否首字母大寫,如果是返回True;否則返回False。實例如下:

    >>> s1 = "Alex is sb"
  >>> s2 = "Alex Is Sb"
  >>> s3 = "alex is sb"
  >>> s1.istitle()
  False
  >>> s2.istitle()
  True
  >>> s3.istitle()
  False
    28.isupper(self)

    def isupper(self): # real signature unknown; restored from __doc__
    """
    S.isupper() -> bool
        判斷所有字母是否都是大寫
    Return True if all cased characters in S are uppercase and there is
    at least one cased character in S, False otherwise.
    """
    return False

      isupper(self)判斷字元串中所有字元是否都是大寫形式:實例如下:

    >>> s1 = "Alex is sb"
  >>> s2 = "Alex Is Sb"
    >>> s3 = "alex is sb"

    >>> s4 = "ALEX IS SB"
    >>> s1.isupper()
  False
  >>> s2.isupper()
  False
  >>> s3.isupper()
  False

    >>> s4.isupper()
  True

    29.join(self,iterable)

    def join(self, iterable): # real signature unknown; restored from __doc__
    """
    S.join(iterable) -> str
        字元串的拼接,把字元串拼接到一起
    Return a string which is the concatenation of the strings in the
    iterable. The separator between elements is S.
    """
    return ""

    join(self,iterable)拼接,字元串和列表直接的拼接,有不同方式的拼接,下麵來研究一下:

    >>> sign = "-"
  >>> name = "alex"
  >>> li = ["a","l","e","x","s","b"]
  >>> l1 = ""
    1.字元串和字元串進行拼接,將拼接中的字元串的每一個元素與字元串中的元素進行拼接,即iterable+self+iterable+self... 

  >>sign.join(name)
  'a-l-e-x'
  >>> name.join("sb")
  'salexb'
  >>> name.join("issb")
  'ialexsalexsalexb'
  2.字元串和列表進行拼接,列表中的每一個元素都與字元串的元素進行拼接:

  >>> sign.join(li)
  'a-l-e-x-s-b'
  >>> l1.join(li)
  'alexsb'

    其實在Python中,字元串存儲的格式就是列表存儲的,比如"alexsb"存儲就是["a","l","e","x","s","b"],因而字元串與列表拼接與字元串與字元串拼接是一樣的。

    30.ljust(self,width,fillchar=None)

    def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.ljust(width[, fillchar]) -> str
       固定長度,字元串左邊拼接指定的字元
    Return S left-justified in a Unicode string of length width. Padding is
    done using the specified fill character (default is a space).
    """
    return ""
    ljust(self,width,fillchar=None),固定長度,self+fillchar,實例如下:

    >>> name = "alexsb"
    >>> name.ljust(12,"-")
  'alexsb------'

    31.rjust(self,width,fillchar=None)

    def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.rjust(width[, fillchar]) -> str

    Return S right-justified in a string of length width. Padding is
    done using the specified fill character (default is a space).
    """
    return ""

    固定字元串長度,在字元串左側鏈接指定字元,實例如下:

    >>> name = "alexsb"   

  >>> name.rjust(12,"-")
  '------alexsb'

    32.lower(self)

    def lower(self): # real signature unknown; restored from __doc__
    """
    S.lower() -> str
        將字元串全部轉化為小寫形式
    Return a copy of the string S converted to lowercase.
    """
    return ""

    33.lstrip(self,chars=None)

    def lstrip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.lstrip([chars]) -> str

    Return a copy of the string S with leading whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    """
    return ""

    lstrip(self,chars=None)是刪除字元串左側的空格,預設是刪除空格,其實可以指定刪除任何字元,實例如下:

    >>> name = "   AlexAesbb   "
  >>> name.lstrip()
  'AlexAesbb   '

    34.rstrip(self,chars=None)

    def rstrip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.rstrip([chars]) -> str
        刪除字元串右側的空格
    Return a copy of the string S with trailing whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    """
    return ""

    rstrip(self,chars=None)刪除字元串右側的空格,實例如下:

    >>> name = "   AlexAesbb   "   

    >>> name.rstrip()
'   AlexAesbb'

    35.strip(self,chars=None)

    def strip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.strip([chars]) -> str

    Return a copy of the string S with leading and trailing
    whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    """
    return ""

     strip(self,chars=None)刪除字元串兩側的空格,示例如下:

    >>> name = "   AlexAesbb   "   

    >>> name.strip()
  'AlexAesbb'

    36.maketrans(self,*args,**kwargs)

    def maketrans(self, *args, **kwargs): # real signature unknown
    """
    Return a translation table usable for str.translate().

    If there is only one argument, it must be a dictionary mapping Unicode
    ordinals (integers) or characters to Unicode ordinals, strings or None.
    Character keys will be then converted to ordinals.
    If there are two arguments, they must be strings of equal length, and
    in the resulting dictionary, each character in x will be mapped to the
    character at the same position in y. If there is a third argument, it
 

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 小分享:我有幾張阿裡雲優惠券,用券購買或者升級阿裡雲相應產品最多可以優惠五折!領券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 0 Asp.Net Core 項目實戰之許可權 ...
  • 小分享:我有幾張阿裡雲優惠券,用券購買或者升級阿裡雲相應產品最多可以優惠五折!領券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 繼續上一篇《開發 ASP.NET vNext ...
  • ASP.NET MVC動態載入數據,一般的做法是使用$.each方法來迴圈產生tabel:你可以在html時先寫下非動態的部分: <table> <tr> <th style="width:10px;"><input id="SelectAll" type="checkbox" /></th> <t ...
  • 模板語法with關鍵字type u struct { Name string Age int Sex string } user:=&u{Name:"asd",Age:20,Sex:"mal"} data["user"]=user c.HTML(http.StatusOK, "index.html"... ...
  • 最近有個奇葩要求 要項目中的N行代碼 申請專利啥的然後作為程式員當然不能複製粘貼 用代碼解決。。使用python-docx讀寫docx文件環境使用python3.6.0首先pip安裝python-docxpip install python-docx然後下麵是腳本 修改目錄,這裡預設取腳本運行目錄下... ...
  • php自動載入原理 sql_autoload_register PSR-4 ...
  • 原題地址: 明明的隨機數 在不同的一些刷題代碼網站和給定的不同題目中,對於給定變數輸入的規則可能會有不同,一般來講,最常見的輸入方法來源於sys.stdin方法 例如這道簡單的題: 1.輸入描述:輸入多行,先輸入隨機整數的個數,再輸入相應個數的整數 2.輸出描述:返回多行,處理後的結果 3.處理要求 ...
  • 1. String fileName=new String(URLEncoder.encode(fileName,"utf-8")); getResponse().addHeader("Content-Disposition","attachment;filename="+fileName); 或者 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...