Python String Reversal(Python String Reversal)
这个练习涉及一个codeacademy问题来编写一个函数,它将一个字符串作为输入并反向输出字符串,我已经找到了如何在线完成它的解决方案,我只是困惑为什么我的工作不起作用:
def reverse(c): empty=[] stringsize= len(c) for x in range(stringsize): empty[x]=c[stringsize-x] return empty
This exercise involves a codeacademy problem to write a function which takes a string as an input and outputs the string in reverse, I've found solutions as to how to do it online, I'm just confused as to why mine doesnt work:
def reverse(c): empty=[] stringsize= len(c) for x in range(stringsize): empty[x]=c[stringsize-x] return empty
原文:https://stackoverflow.com/questions/21578688
更新时间:2022-05-12 17:05
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
弄清楚我自己的问题。 如果其他人感兴趣的话,这就是我最终使用的内容......虽然我使用了很多属性。 Import-Module ActiveDirectory $users = Import-Csv -Path c:\update.csv foreach ($user in $users) { Get-ADUser -Filter "employeeID -eq '$($user.employeeID)'" -Properties * -SearchBase "ou=Test,ou=Our ...
-
如何处理两个简单的循环(假设名称是唯一的),如下所示: $file = Import-CSV C:\example.csv $Users = get-ADUser -searchbase "OU=users,OU=company,DC=blah,DC=blah,DC=com" -filter * -properties name, physicaldeliveryofficename | Select name, physicaldeliveryofficename foreach ($user in $u ...
-
Search-ADAccount只返回用户属性的一个子集。 通过Get-ADUser搜索结果以获取所有属性并通过`Select-Object: $props = 'Name', 'DisplayName', 'EmailAddress', 'Description', 'Enabled' Search-ADAccount –AccountDisabled -UsersOnly | Get-ADUser -Properties $props | Select $props | Exp ...
-
按员工编号禁用csv文件中的用户,然后移动到某个OU中(Disable Users in a csv file by employee number and then move into certain OU)[2023-06-10]
您的Get-ADUser命令使用LDAPFilter参数,但不使用LDAP过滤语法。 这里有两个选项,将参数更改为-Filter或更改过滤器组合。 Get-ADUser -Filter Get-ADUser -Filter "EmployeeNumber -eq $($u.Emp)" Get-ADUser -LDAPFilter Get-ADUser -LDAPFilter "(EmployeeNumber=$($u.Emp))" Your Get-ADUser command is using the ... -
你得到你所得到的原因是因为你没有传递正确的信息,并且你还有其他一些错误。 您没有名为$ Imported_csv的填充变量。 你有一个名为$ Move的填充变量。 你的块应该看起来像这样... $Move = Import-Csv -Path "F:\Desktop\MoveMe.csv" $Move | ForEach-Object { get-aduser -Identity $_.User | move-adobject -TargetPath $_.OU -whatif 'Us ...
-
只需将CSV中的名称与AD中的名称进行比较(我将假定CSV的列标题为Name ): $ADNames = Get-ADComputer -Filter * | Select-Object -Expand Name Import-Csv 'C:\path\to\input.csv' | Where-Object { $ADNames -notcontains $_.Name } | Export-Csv 'C:\path\to\not_in_AD.csv' -NoType 附注: $AD-N ...
-
尝试这个: Import-Module ActiveDirectory $Test_Users = Get-ADGroupMember Test_Users $Data = Import-Csv .\Data.csv Compare-Object $Data $Test_Users -Prop sAMAccountName -Include -Exclude | % { $account = $_.sAMAccountName $Data | ? { $_.sAMAccountName -eq ...
-
如何使用CSV工作表中的PowerShell向AD用户添加信息(How to add info to the AD users with powershell from a CSV sheet)[2024-04-26]
我在这里摇摇欲坠,因为我之前从未使用过AD命令,但它应该是这样的: Import-Module activedirectory $company = "International" $users = Import-Csv c:\user.csv $users # dumps users to allow visual inspection read-host "press Enter to continue or Ctrl+C to abort" $users | Foreach {Set-ADUser ... -
在不知道CSV的确切结构的情况下,我将假设它是这样的:“CN =”,“OU =”,“DC =”“JSmith”,“Accounting”,“Foo.com”“BAnderson”, “HR”,“Foo.com”“JAustin”,“IT”,“Foo.com” 也就是说,如果您的第一个字段实际上包含CN =(即“CN = JSmith”,“OU = Accounting”,“Foo.com”),您将需要使用.TrimStart("CN=")修剪它。 $ToRemove = Import-CSV UserLis ...