第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

初識Python

廖雪峰 移動開發(fā)工程師
難度入門
時長 5小時 0分
學習人數(shù)
綜合評分9.43
3762人評價 查看評價
9.7 內(nèi)容實用
9.4 簡潔易懂
9.2 邏輯清晰
  • gc
    空數(shù)組和單元素數(shù)組 空數(shù)組 PS C:Powershell> $a=@() PS C:Powershell> $a -is [array] True PS C:Powershell> $a.Count 0 1個元素的數(shù)組 PS C:Powershell> $a=,"moss" PS C:Powershell> $a -is [array] True PS C:Powershell> $a.Count 1
    查看全部
  • gc
    數(shù)組的多態(tài) 象變量一樣如果數(shù)組中元素的類型為弱類型,默認可以存儲不同類型的值。 PS C:Powershell> $array=1,"2012世界末日",([System.Guid]::NewGuid()),(get-date) PS C:Powershell> $array 1 2012世界末日 Guid ---- 06a88783-a181-4511-9e41-2780ecbd7924 DisplayHint : DateTime Date : 2011/12/9 0:00:00 Day : 9 DayOfWeek : Friday DayOfYear : 343 Hour : 14 Kind : Local Millisecond : 910 Minute : 15 Month : 12 Second : 45 Ticks : 634590369459101334 TimeOfDay : 14:15:45.9101334 Year : 2011 DateTime : 2011年12月9日 14:15:45
    查看全部
  • gc
    在Powershell中創(chuàng)建數(shù)組可以使用逗號。 PS C:Powershell> $nums=2,0,1,2 PS C:Powershell> $nums 2 0 1 2 對于連續(xù)的數(shù)字數(shù)組可以使用一個更快捷的方法 PS C:Powershell> $nums=1..5 PS C:Powershell> $nums 1 2 3 4 5
    查看全部
  • gc
    使用真實的對象操作 為什么不愿把IPconfig返回的結(jié)果稱為對象,因為它不是真正Cmdlet命令,真正的Powershell命令返回的數(shù)組元素可不止一個字符串,它是一個內(nèi)容豐富的對象。 PS C:Powershell> ls Directory: C:Powershell Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 2011/11/23 17:25 ABC d---- 2011/11/29 18:21 myscript -a--- 2011/11/24 18:30 67580 a.html -a--- 2011/11/24 20:04 26384 a.txt -a--- 2011/11/24 20:26 12060 alias 數(shù)組的每一個元素存放的是一個System.IO.DirectoryInfo對象。 當我們輸出這些對象時,Powershell會自動幫我們把它轉(zhuǎn)換成友好的文本格式。 PS C:Powershell> $result[0].gettype().fullname System.IO.DirectoryInfo PS C:Powershell> $result[0] Directory: C:Powershell Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 2011/11/23 17:25 ABC 對于任何一個對象都可以使用Format-List * 查看它所有的屬性和方法。 PS C:Powershell> $result[0] | fl *
    查看全部
  • gc
    使用數(shù)組存儲結(jié)果 判斷一個變量是否為數(shù)組 PS C:Powershell> $ip=ipconfig PS C:Powershell> $ip -is [array] True PS C:Powershell> "abac" -is [array] False PS C:Powershell> $str="字符串" PS C:Powershell> $str.ToCharArray() -is [array] True 查看數(shù)組的元素個數(shù)用$array.Count屬性。訪問第x個元素,使用$array[x-1],因為數(shù)組是以0開始索引的。 使用管道對數(shù)組進一步處理 PS C:Powershell> ipconfig | Select-String "IP" Windows IP Configuration Link-local IPv6 Address . . . . . : *** IPv4 Address. . . . . . . . . . . : *** Link-local IPv6 Address . . . . . : ***
    查看全部
  • gc
    當我們把一個命令的執(zhí)行結(jié)果保存到一個變量中,可能會認為變量存放的是純文本。 但是,事實上Powershell會把文本按每一行作為元素存為數(shù)組。如果一個命令的返回值不止一個結(jié)果時,Powershell也會自動把結(jié)果存儲為數(shù)組。 PS C:Powershell> $IPcfg=ipconfig PS C:Powershell> $IPcfg Windows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : *** Link-local IPv6 Address . . . . . : *** IPv4 Address. . . . . . . . . . . : 192.168.140.128 Subnet Mask . . . . . . . . . . . : 255.255.252.0 Default Gateway . . . . . . . . . : 192.168.140.1 Tunnel adapter isatap.mossfly.com: Connection-specific DNS Suffix . : *** Link-local IPv6 Address . . . . . : *** Default Gateway . . . . . . . . . :*** Tunnel adapter Teredo Tunneling Pseudo-Interface: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : PS C:Powershell> $IPcfg.Count 22
    查看全部
  • gc
    ValidateRangeAttribute 例子,驗證月份1-12 PS> $month=1 PS> (Get-Variable month).Attributes.Add( $( New-Object System.Management.Automation.ValidateRangeAttribute -ArgumentList 1,12) ) PS> $month=10 PS> $month=12 PS> $month=18 The variable cannot be validated because the value 18 is not a valid value for the month variable. At line:1 char:7 + $month <<<< =18 + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure ValidateSetAttribute 例子,驗證性別 PS> $sex="男" PS> $con=New-Object System.Management.Automation.ValidateSetAttribute -ArgumentList "男","女","保密" PS> (Get-Variable sex).Attributes.Add($con) PS> $sex="女" PS> $sex="不男不女" The variable cannot be validated because the value 不男不女 is not a valid value for the sex variable.
    查看全部
  • gc
    ValidatePatternAttribute 例子,驗證Email格式 PS> $email="test@mossfly.com" PS> $con=New-Object System.Management.Automation.ValidatePatternAttribute "b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}b" PS> (Get-Variable email).Attributes.Add($con) PS> $email="abc@abc.com" PS> $email="abc@mossfly.com" PS> $email="author@gmail.com" PS> $email="www@mossfly" The variable cannot be validated because the value www@mossfly is not a valid value for the email variable. At line:1 char:7 + $email <<<< ="www@mossfly" + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure
    查看全部
  • gc
    ValidateNotNullOrEmptyAttribute 例子,注意@()為一個空數(shù)組。 PS> $con=New-Object System.Management.Automation.ValidateNotNullOrEmptyAttribute PS> (Get-Variable a).Attributes.clear() PS> (Get-Variable a).Attributes.add($con) PS> $a=$null The variable cannot be validated because the value is not a valid value for the a variable. At line:1 char:3 + $a <<<< =$null + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure PS> $a="" The variable cannot be validated because the value is not a valid value for the a variable. At line:1 char:3 + $a <<<< ="" + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure PS> $a=@() The variable cannot be validated because the value System.Object[] is not a valid value for the a variable. At line:1 char:3 + $a <<<< =@() + CategoryInfo : MetadataError: (:) [], ValidationMetadataException
    查看全部
  • gc
    ValidateNotNullAttribute 例子 PS> $a=123 PS> $con=New-Object System.Management.Automation.ValidateNotNullAttribute PS> (Get-Variable a).Attributes.Add($con) PS> $a=8964 PS> $a=$null 無法驗證此變量,因為值 不是變量 a 的有效值。 所在位置 行:1 字符: 3 + $a <<<< =$null + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure
    查看全部
  • gc
    驗證和檢查變量的內(nèi)容 變量PSVariable對象的Attributes屬性能夠存儲一些附件條件,例如限制變量的長度,這樣在變量重新賦值時就會進行驗證,下面演示如何限制一個字符串變量的長度為位于2-5之間。 PS> $var="限制變量" PS> $condition= New-Object System.Management.Automation.ValidateLengthAttribute -ArgumentList 2,5 PS> (Get-Variable var).Attributes.Add($condition) PS> $var="限制" PS> $var="射雕英雄傳" PS> $var="看射雕英雄傳" The variable cannot be validated because the value 看射雕英雄傳 is not a valid value for the var variable. At line:1 char:5 + $var <<<< ="看射雕英雄傳" + CategoryInfo : MetadataError: (:) [], ValidationMetadataException + FullyQualifiedErrorId : ValidateSetFailure 常用的變量內(nèi)容驗證還有5種,分別為: ValidateNotNullAttribute:限制變量不能為空 ValidateNotNullOrEmptyAttribute:限制變量不等為空,不能為空字符串,不能為空集合 ValidatePatternAttribute:限制變量要滿足制定的正則表達式 ValidateRangeAttribute:限制變量的取值范圍 ValidateSetAttribute:限制變量的取值集合
    查看全部
  • gc
    變量的類型規(guī)范 每個變量的都有自己的類型,這個具體的類型存放在PsVariable對象的Attributes[System.Management.Automation.PSVariableAttributeCollection]屬性,如果這個Attributes為空,可以給這個變量存放任何 類型的數(shù)據(jù),Powershell會自己選擇合適的類型。一旦這個Attributes屬性確定下來,就不能隨意存放數(shù)據(jù)了。例如給$var存放一個整數(shù),屬于弱類型,所以Attributes屬性為空,這時還可以給它賦值一個字符串。但是如果給$var增加強類型,存放一個整數(shù),再給它賦值一個其它類型,解釋器會自動嘗試轉(zhuǎn)換,如果不能轉(zhuǎn)換就會拋出異常。這時如果你非得更新$var變量的類型,可以使用 (Get-Variable var).Attributes.Clear(),清空Attributes,這樣強類型就又轉(zhuǎn)換成弱類型了。 PS> $var=123 PS> (Get-Variable var).Attributes PS> $var.GetType().FullName System.Int32 PS> $var="字符串" PS> (Get-Variable var).Attributes PS> $var.GetType().FullName System.String PS> [int]$var=123 PS> (Get-Variable var).Attributes TypeId ------ System.Management.Automation.ArgumentTypeConverterAttribute PS> $var.GetType().FullName System.Int32 PS> $var="2012" PS> $var 2012 PS> $var.GetType().FullName System.Int32 PS> $var="2012世界末日" Cannot convert value "2012世界末日" to type "System.Int32". Error: "Input string was not in a correct format."
    查看全部
  • gc
    激活變量的寫保護 可以操作一個變量的選項設置 ,比如給一個變量加上寫保護,需要將Option設置為“ReadOnly” PS> $var="mossfly" PS> Set-Variable var -Option "ReadOnly" PS> (Get-Variable var).Options ReadOnly PS> Set-Variable var -Option "None" -Force PS> (Get-Variable var).Options None 變量的選項 變量的選項是一個枚舉值,包含: “None”:默認設置 “ReadOnly”:變量只讀,但是可以通過-Force 選項更新。 “Constant”:常量一旦聲明,在當前控制臺不能更新。 “Private”:只在當前作用域可見,不能貫穿到其它作用域 “AllScope”:全局,可以貫穿于任何作用域
    查看全部
  • gc
    修改變量的選項設置 Powershell處理一個變量的PSVariable對象,主要是為了能夠更新變量的選項設置。既可以使用命令Set-Variable,也可以在獲取PSvariable對象后直接更改。比如更改一個變量的描述: PS> $str="我是一個變量" PS> $var=Get-Variable str PS> $var Name Value ---- ----- str 我是一個變量 PS> $var | fl * Name : str Description : Value : 我是一個變量 Visibility : Public Module : ModuleName : Options : None Attributes : {} PS> $var.Description="我知道你是一個變量" PS> $var | fl * Name : str Description : 我知道你是一個變量 Value : 我是一個變量 Visibility : Public Module : ModuleName : Options : None Attributes : {} 如果你不想多加一個臨時變量$var來存儲PSVariable,可以使用Powershell子表達式 PS> (Get-Variable str).Description="變量的描述已更改;" PS> Get-Variable str | Format-Table Name,Description Name Description ---- ----------- str 變量的描述已更改
    查看全部
  • gc
    在Powershell中創(chuàng)建一個變量,會在后臺生成一個PSVariable對象,這個對象不僅包含變量的值,也包含變量的其它信息,例如”只寫保護”這樣的描述。 如果在Powershell中輸出一個變量,只會輸出這個變量的值。不能夠顯示它的其它信息,如果想查看一個變量的其它保留信息,就需要變量的基類PSVariable對象,這個可以通過Get-Variable命令得到,下面的例子演示如何查看一個變量的全部信息。 PS> $a=get-date PS> Get-Variable a Name Value ---- ----- a 2011/12/8 17:52:02 PS> Get-Variable a | fl * Name : a Description : Value : 2011/12/8 17:52:02 Visibility : Public Module : ModuleName : Options : None Attributes : {}
    查看全部

舉報

0/150
提交
取消
課程須知
如果您了解程序設計的基本概念,會簡單使用命令行,了解中學數(shù)學函數(shù)的概念,那么對課程學習會有很大的幫助,讓您學起來得心應手,快速進入Python世界。
老師告訴你能學到什么?
通過本課程的學習,您將學會搭建基本的Python開發(fā)環(huán)境,以函數(shù)為基礎編寫完整的Python代碼,熟練掌握Python的基本數(shù)據(jù)類型以及l(fā)ist和dict的操作。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網(wǎng)的支持!