def Corner(n):
if n == 3:
print('İts An Triangle \nBu Bir Üçgen')
elif n == 4:
print('İts An Rectangle or Square or Parrallelogram \nBu Bir
Dikdörtgen yada Kare yada ParalelKenar ')
elif n == 5:
print('İts An Pentagon \nBu Bir Beşgen')
elif n == 6:
print('İts An Hexagon \nBu Bir Altıgen')
else:
print('Bir Köşe Sayısı Girmediniz \nYou Didnt Wrote a Corner
Number '
print Corner(6)
**File "Köşegen.py", line 13
print Corner(6)
^
SyntaxError: invalid syntax**
我在Python3上写的错误代码 这个代码关于角落和形状,但我在运行代码时进行了按摩
答案 0 :(得分:2)
你错过了一些括号:
# example data saved in .\compinfo.csv:
hname,ip
comp1,192.168.1.10
comp2,192.168.1.11
# importing the example data
$compinfo = import-csv .\compinfo.csv
$lookupData = foreach($comp in $compinfo)
{
$nslkup = [System.Net.DNS]::GetHostEntry($comp.hname)
$ping = (Test-Connection -ComputerName $comp.hname -Count 1 -ErrorAction SilentlyContinue)
if($ping)
{
$status = "up"
}
else
{
$status = "down"
}
if($nslkup.AddressList.IPAddressToString -eq $comp.ip)
{
$ipgood = $true
}
else
{
$ipgood = $false
}
[pscustomobject]@{
computerName = $comp.hname
expectedIp = $comp.ip
status = $status
goodIp = $ipgood
dnsName = $nslkup.hostname
}
}
$lookupData | export-csv .\lookups.csv -NoTypeInformation
答案 1 :(得分:0)
在python 3中,print就像其他任何函数一样,所以你需要括号,如下所示:
print(' something ')
而不是:
print ' something '
在python 2中
答案 2 :(得分:0)
我关闭了Parantheses及其工作感谢帮助Artemis Fowl和Todd W
def Corner(n):
if n == 3:
print('İts An Triangle \nBu Bir Üçgen')
elif n == 4:
print('İts An Rectangle or Square or Parrallelogram \nBu Bir
Dikdörtgen yada Kare yada ParalelKenar')
elif n == 5:
print('İts An Pentagon \nBu Bir Beşgen')
elif n == 6:
print('İts An Hexagon \nBu Bir Altıgen')
else:
print('Bir Köşe Sayısı Girmediniz \nYou Didnt Wrote a Corner Number')
print(Corner(6))